Skip to content

Instantly share code, notes, and snippets.

@iannono
Last active December 20, 2015 00:49
Show Gist options
  • Save iannono/6044786 to your computer and use it in GitHub Desktop.
Save iannono/6044786 to your computer and use it in GitHub Desktop.
angularJS学习笔记
//在controller和directive中定时修改作用域模型的方式
app.controller('generalCtrl', ['$scope', function($scope) {
$scope.pv = 0;
//通过调用apply触发内部的direct循环,从而更新作用域和模型
setInterval(function(){$scope.$apply()}, 1000);
}])
directives.directive('rtIp', function(){
return function(scope, elm, attrs) {
setInterval(function(){scope.pv = scope.pv + 1;}, 1000);
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment