What is the default for AngularJS directive scope?

后端 未结 2 1677
执念已碎
执念已碎 2020-12-31 06:31

What is the default scope value of an AngularJS directive?

Of course, it is not isolated scope. It is true or false.

I can\'t find any documentation on wha

相关标签:
2条回答
  • 2020-12-31 07:14

    "Note, by default, directives do not create new scope -- i.e., the default is scope: false"

    from Understanding scopes.

    Using the scope option in directive you can:

    • create a child scope prototypically inherited with scope: true
    • create an isolated scope with scope: {} then you can bind some property to parent scopes with '@', '&', '=' (see this question).
    • decide to not create a new scope and use parent with scope: false (default).
    0 讨论(0)
  • 2020-12-31 07:14

    By default, directives shared the scope of the containing controller. You can specify scope:true to have a inherited scope and to get a isolated scope you have to do the following

    scope:{
    something1:"@",
    something2:"="
    something3:"&"
    }
    
    0 讨论(0)
提交回复
热议问题