如果从角度代码更新模型,则选择选项不会更新视图

时间:2016-04-04 10:31:40

标签: javascript angularjs

Html代码

<select class="form-control" ng-model="schedule.nthSelectThe" style="margin-top: 5px;">
    <option ng-selected="true">first</option>
    <option>second</option>
    <option>third</option>
    <option>fourth</option>
    <option>last</option>
</select>

Angular Code

var freq_relative_intervalRevers ={
    '1':'first',
    '2':'second',
    '4':'third',
    '8':'fourth',
    '16':'last'
 };
 $scope.$applyAsync(function () {                                  
   $scope.schedule.nthSelectThe = freq_relative_intervalRevers[editRecord.freq_relative_interval.toString()];                                    
 });

更新没有反映出来 即使我尝试没有$ applyAsunc像

$scope.schedule.nthSelectThe = freq_relative_intervalRevers[editRecord.freq_relative_interval.toString()];                                    

我检查了变量$scope.schedule.nthDayThe
即使在console.log()值中也是如此,但在视图中,部分首先显示为已选中。

请建议我解决一下。

0 个答案:

没有答案