The significance feature of Angularjs is Directive. Angularjs is HTML enhanced for web apps. Means, developer can introduce new HTML element (eg: <datatable>) or new attribute ( goTo=””) whenever needed and write a script for their behavior. We should know about the scope of directives. So that we can write Directive efficiently.

I assume that you have some prior knowledge regarding directive. This post explains the type of scope can be used for directives.

1. scope: false (Default)

This is default behavior. you can get the parent scope inside directive and this scope will be act as two-way data binding. Means, if you change the scope inside directive, then it will be changed in parent.

Example: (Check country scope/model)

Code:

2. scope: true (Inherit scope)

You can get the parent scope inside directive and this scope will be act as one-way data binding. Means, if you change the scope inside directive, then it will not be changed in parent.

Example: (Check country scope/model)

Code:

 

3. scope:{} (Isolated scope)

You can pass particular scopes inside directive through attributes and you may decide whether these scopes will be act as two-way data binding (=) or one-way data binding (@).

Example: (two-way data binding) (Check country scope/model)

Code:

 

Example: (one-way data binding) (Check country scope/model)

Code: