angularjs - Move from final 1.3 rc to 1.3.0 - <select> option problems after <select> bug fixes made in the move -
my application has html:
<select id="contenttypeselect" ng-change="home.configchanged(true)" ng-model="ctrl.configservice.admin.contenttypeid" ng-options="item.id item.name item in content"></select>
here value of content:
var content = [{"id":0,"name":"*"}, {"id":1,"name":"menu"}, {"id":2,"name":"service"}, {"id":3,"name":"help"}, {"id":4,"name":"product"}, {"id":5,"name":"version"}, {"id":6,"name":"exam"}, {"id":7,"name":"track"}]
my problem creates select blank entry:
<select id="contenttypeselect" ng-change="home.configchanged(true)" ng-model="ctrl.configservice.admin.contenttypeid" ng-options="item.id item.name item in content" class="ng-pristine ng-untouched ng-valid"> <option value="? string: ?"> </option><option value="0" selected="selected">*</option> <option value="1">menu</option> <option value="2">service</option> <option value="3">help</option> <option value="4">product</option> <option value="5">version</option> <option value="6">exam</option> <option value="7">track</option> </select>
can help explain me why line in html:
<option value="? string: ?">
here how populating select data:
self.content = results[2]; self.configservice.admin.contenttypeid = self.content[0].id;
first populate info in self.content , set modal id of first element of array.
note problem production 1.3 release. not seeing problem beta.
> @license angularjs v1.3.0-beta.8 // release working me > @license angularjs v1.3.0-rc.3 // release working me > @license angularjs v1.3.0-rc.5 // release working me > @license angularjs v1.3.0 // release failing me
i assume alter result of next alter made between rc5 , production release:
1.3.0 superluminal-nudge (2014-10-13) bug fixes select: add together basic track , select back upwards (addfff3c, #6564) manage select controller options correctly (2435e2b8, #9418)
i this. bug prepare did not introduce new bug facing. code appears work in versions prior 1.3.0
please note order application works.
a) open html b) info select list (takes 5 seconds) c) populate ng-options d) populate ng-model
could problem related bug prepare added before release of 1.3.0 options. same code has been working year , giving me problem latest 1.3.0 release.
this seems known bug v1.3.0
(see: https://github.com/angular/angular.js/issues/9714 , https://github.com/angular/angular.js/issues/9691).
the bug in someway triggered async assignment of ngoptions
model info , pre-selecting value falsy identifier (e.g. ''
or 0
). can reproduced follows:
class="snippet-code-js lang-js prettyprint-override">(function (app, ng) { 'use strict'; app.controller('appctrl', ['$timeout', function($timeout) { var vm = this; $timeout(function () { vm.content = [ { id: 0, name: 'a' }, { id: 1, name: 'b' }, { id: 2, name: 'c' } ]; }, 1000); }]); }(angular.module('app', []), angular));
class="snippet-code-html lang-html prettyprint-override"><script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.min.js"></script> <div data-ng-app="app"> <!-- wrong behavior --> <div data-ng-controller="appctrl app1" data-ng-init="app1.selected = 0;"> <select data-ng-model="app1.selected" data-ng-options="item.id (item.name + ' [' + item.id + ']') item in app1.content" size="4" ></select> </div> <!-- right behavior --> <div data-ng-controller="appctrl app2" data-ng-init="app2.selected = 1;"> <select data-ng-model="app2.selected" data-ng-options="item.id (item.name + ' [' + item.id + ']') item in app2.content" size="4" ></select> </div> </div>
angularjs
No comments:
Post a Comment