AngularJS ng-bind未更新

时间:2015-03-09 20:44:31

标签: javascript angularjs web-services ng-bind

<div class="btn-group dd-rm-action" role="group" aria-label="...">
    <button type="button" class="btn btn-primary dd-action pagination-centered" ng-click="Save()">Save</button>
    <button class="btn btn-default dd-action dropdown-toggle" type="button" id="dropdownState" data-toggle="dropdown" aria-expanded="true" ng-bind="rmCW.State.Name">
        <b class="caret"></b>
    </button>
    <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownState">
        <li role="presentation" ng-repeat="task in docState.Tasks">
            <a role="menuitem" tabindex="{{$index}}" href="#" ng-click="execTask(task)">{{task.Name}}</a>
        </li>
    </ul>
</div>

我有一个angularjs应用程序,只要更新范围值后按钮的ng-bind不会更新,就可以正常工作:

result.then(function (r) {
    $scope.$emit('UNLOAD');
    if (r.status == 0) {
        var cs = JSON.parse(r.data)
        $scope.docState = cs;
        $scope.rmCW.Current = cs;
    }
}

1 个答案:

答案 0 :(得分:1)

很可能是因为ng-bind="rmCW.State.Name"并且您的范围设置为其他属性。

 $scope.rmCW.Current = cs;

您需要将ng-bind设置为ng-bind="rCW.Current.Name",或者您需要将$ scope设置为$scope.rmCW.State = cs;