【问题标题】:Angular view not updating controller variable角度视图不更新控制器变量
【发布时间】:2016-03-01 09:56:57
【问题描述】:

通过部分更改控制器中的值后,我的角度视图没有更新。当我执行 console.log 时,它会记录更改的值。

测试控制器

$scope.testitem = 0;

$scope.updatePagination = function(page, lastPage) {
    console.log('Test ', + page + " " + lastPage); //works
    $scope.testitem = page; //doesnt work
};

查看

p(ng-model="testitem") {{testitem}} test
div(st-pagination="", st-items-by-page="displayAmount", st-displayed-pages="7", class="pagination" st-template="/partials/pagination.custom.html")

分页.custom.html

nav(ng-if='pages.length >= 2')
ul.pagination
    li.non-clickable(ng-repeat="page in pages", ng-class="{active: page==currentPage}", ng-controller="controller")
        a( ng-click='selectPage(page); updatePagination(page, numPages)') {{page}}

【问题讨论】:

    标签: angularjs view controller smart-table


    【解决方案1】:

    尝试以下操作,您可能需要告诉视图范围已更新。

    $scope.apply(function(){
        $scope.testitem = page; //doesnt work
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-17
      • 2015-12-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-21
      • 1970-01-01
      相关资源
      最近更新 更多