首页 > 其他 > 详细

angular attrs.$observe和$scope.$watch的区别

时间:2015-09-05 23:40:43      阅读:1331      评论:0      收藏:0      [点我收藏+]

  http://stackoverflow.com/questions/14876112/difference-between-the-observe-and-watch-methods

https://docs.angularjs.org/api/ng/type/$compile.directive.Attributes

$observe()是Attributes 对象的一个方法,它只能用于observe/watch一个DOM attribute的value change.它只在directive内部被调用。当你需要监察、侦听一个包含interpolation的attribute的DOM时,你需要使用$observe()函数(比如:{{attrValue}}

$watch被用于监察、侦听一个model/scope属性,比如:scope.$watch(attrs.attr1)...

注意:angular normalize string

angular attrs.$observe和$scope.$watch的区别

原文:http://www.cnblogs.com/kidsitcn/p/4784205.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!