Accessing attributes from an AngularJS directive

前端 未结 2 985
死守一世寂寞
死守一世寂寞 2020-11-28 03:01

My AngularJS template contains some custom HTML syntax like:

{{field.su_name}}
         


        
2条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-28 03:15

    See section Attributes from documentation on directives.

    observing interpolated attributes: Use $observe to observe the value changes of attributes that contain interpolation (e.g. src="{{bar}}"). Not only is this very efficient but it's also the only way to easily get the actual value because during the linking phase the interpolation hasn't been evaluated yet and so the value is at this time set to undefined.

提交回复
热议问题