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

  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}},再比如select控件,当你选择一个option时,如果对应的属性作为触发过滤结果集这种场景时,可以$observe这个选择动作的结果(作为attr)

<div d1 attr1="{{prop1}}-test" attr2="prop2" attr3="33" attr4="'a_string'"
        attr5="a_string" attr6="{{1+aNumber}}"></div>

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

注意:angular normalize string