Why is the combination of a $watch, a promise and ng-options behaving differently in angularJS 1.3? -
after upgrading angularjs 1.2 1.3 have issue ng-options. selected value not shown in browser.
i've got html select:
<select ng-model="selectedfield" ng-options="field field in fields"></select>
after setting selectedfield , loading fields (via promise) angularjs 1.2 works fine. angularjs 1.3 selected value not shown.
changing ng-options query using "track by" option makes work in angularjs 1.3 again.
<select ng-model="selectedfield" ng-options="field field in fields track field"></select>
i discovered coincidence. in case "track by" should not needed fields list of strings. , selectedfield string well. default comparison used ng-options should work.
this works i'm not happy. not make sense , need solution understand.
i continued examination of issue , found out using $watch uses promise load data $scope.fields "toxic" combination.
- if call promise directly controller works fine in angularjs 1.3.
- if bind list of values in $watch works fine well.
- if use both ($watch , promise) breaks.
show me code! http://plnkr.co/edit/a58nd61tni3g4l7gqz5l?p=preview
in plunker there 3 cases:
- case 1: promise , ng-options works fine in 1.3
- case 2: $watch , ng-options works fine in 1.3
- case 3: $watch, promise , ng-options not work in 1.3
and mention again: cases work fine if add "track by" option. or use angularjs 1.2.
can explain me why case 3 not working anymore when using angularjs 1.3. using "track by" looks hack in case , doesn't feel right. , above understand code working is!
good observation blazemonger: 2 options selected="selected":
in both selects 2 values selected.
but (in angular 1.3?) causing this?
Comments
Post a Comment