Use of symbols '@', '&', '=' and '>' in custom directive's scope binding: AngularJS

后端 未结 6 1759
北恋
北恋 2021-01-29 17:53

I have read a lot about the use of these symbols in the implementation of custom directives in AngularJS but the concept is still not clear to me.

What does it mean if I

6条回答
  •  萌比男神i
    2021-01-29 18:35

    When we create a customer directive, the scope of the directive could be in Isolated scope, It means the directive does not share a scope with the controller; both directive and controller have their own scope. However, data can be passed to the directive scope in three possible ways.

    1. Data can be passed as a string using the @ string literal, pass string value, one way binding.
    2. Data can be passed as an object using the = string literal, pass object, 2 ways binding.
    3. Data can be passed as a function the & string literal, calls external function, can pass data from directive to controller.

提交回复
热议问题