angular1.5,$scope.$apply()强制更新

改变数据,视图不刷新的情况下,请加上$scope.$apply();

$scope.$apply(function() {
    var leftNewVal = (left / 0.5 + (mouseMoveX - mouseDownX) / 0.5);
    var topNewVal = (top / 0.5 + (mouseMoveY - mouseDownY) / 0.5);
    $scope.templatePosition.index[curKeyName].left = leftNewVal;
    $scope.templatePosition.index[curKeyName].top = topNewVal;
})

$scope.$watch('templatePosition',function(obj){
     $scope.progressStyle($scope .templatePosition);
}, true);

angular1传值

当时有个需求,内容发生变化,导航菜单也要跟随变化,于是就想到传值

$rootScope.$broadcast(‘name’, ‘a’); 此方法用于传值,类似与发消息,将key为name, value为a的参数发出去

接收

$rootScope.$on(‘name’, function(event, args) {

// args为值

console.log(args);

})

需要在接收的地方用。

angular ui bootstrap 分页控件

<h6><code>boundary-link-numbers</code> set to <code>true</code> and <code>rotate</code> defaulted to <code>true</code>:</h6>
    <ul uib-pagination total-items="bigTotalItems" ng-model="bigCurrentPage" max-size="maxSize" class="pagination-sm" boundary-link-numbers="true"></ul>