angularjs - Breezejs + Angular - How to Properly Map Database Property Names? -
i have working , reusable custom <select>
directive populates via ng-options
, here snippet:
ng-options="datum.name datum in data track datum.id"
this works intended when use local test json file populate can define name
, id
properties manually. when using breezejs (which pulling data expected), database has product
, deviceid
instead of desired name
, id
properties.
i want able pull data, map product
, deviceid
name
, id
doing ensures goal of reusability of custom <select>
directive. many different entities need map name
, id
, important reusability.
how accomplish this? i've looked @ mapping json entities , jsonresultsadapter thinking right direction. unfortunately, these examples seem missing need (unless i'm missing something).
are there other solutions or ways tackle problem? there best practice way of doing using breezejs? thank in advance light can shed.
*found solution
i using custom directive (but add options-map
attribute):
<sel-select-box id="selectboxdevice1" select-size="10" options-map="datum.product datum in data track datum.deviceid" service-in="devicesearchdataservice" service-in-watch="getdevice1matches" service-in-restore="getdevice1selection" service-out="devicesearchdataservice" service-out-send="updatedevice1selection"> </sel-select-box>
then in reusable <select>
reference {{optionsmap}}
so:;
<select class="form-control" ng-model="selected" ng-change="onchange()" ng-click="onclick()" ng-options="{{optionsmap}}" data-ng-attr-size="{{selectsize}}"> </select>
as result can use numerous custom <sel-select-box>
directives , add proper map string <select>
's ng-options
utilizes.
i'm super stoked works , achieves flexibility desire, i'm still open improved ideas and/or suggestions.
have looked @ custom namingconvention? nc dedicated business of mapping between client-side , server-side entity property names
Comments
Post a Comment