Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the default for AngularJS directive scope?

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 what it is.

like image 678
Aladdin Mhemed Avatar asked Feb 26 '14 06:02

Aladdin Mhemed


People also ask

What is =? In AngularJS?

Locals definition is a hash of local scope property to its source: = or =attr - set up bi-directional binding between a local scope property and the parent scope property of name defined via the value of the attr attribute.

What are the directives in AngularJS?

AngularJS directives are extended HTML attributes with the prefix ng- . The ng-app directive initializes an AngularJS application. The ng-init directive initializes application data. The ng-model directive binds the value of HTML controls (input, select, textarea) to application data.

What is the scope of scope in AngularJS?

AngularJS Scope The scope is the binding part between the HTML (view) and the JavaScript (controller). The scope is an object with the available properties and methods. The scope is available for both the view and the controller.


1 Answers

"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).
like image 185
glepretre Avatar answered Sep 26 '22 14:09

glepretre