angularjs - Empty Option field in Select tag - Angualr js -
i getting empty option field in select tag.
my code shown below:
openselectboxmodel="47" openselectlist=[{id:""47",name:"text"}]; valuekey="id"; titlekey="name"; <select id="reportopenselectboxsingle" size="6" ng-style='selectstyle' class="openselectbox" ng-model="openselectboxmodel" ng-change="changefn()" > <option ng-selected="openselectboxmodel===item[valuekey]" ng-repeat="item in openselectlist" id="" ng-value="{{item[valuekey]}}" ng-title="{{item[titlekey]}}" ng-bind="item[titlekey]"></option> </select>
please me solve problem.
you should not use ng-selected ng-model.
the thing bind selected item ng-model before displaying it.
//also, instead of ng-repeat, should use ng-option
far performance regarded : ng-options not create child scopes every iteration. when angular performs digest, ng-repeat slow it. if have list hundreds of elements, feel difference.
<select id="reportopenselectboxsingle" size="6" ng-style='selectstyle' class="openselectbox" ng-model="openselectboxmodel" ng-change="changefn()" > <option ng-repeat="item in openselectlist" value="{{item[valuekey]}}" title="{{item[titlekey]}}" ng-bind="item[titlekey]"> </option> </select>
furthermore, need declare variables inside controller :
$scope.openselectboxmodel="47"; $scope.openselectlist=[{id:"47",name:"text"}]; $scope.valuekey="id"; $scope.titlekey="name";
Comments
Post a Comment