Last active
December 20, 2015 00:49
-
-
Save iannono/6044786 to your computer and use it in GitHub Desktop.
angularJS学习笔记
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//在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