Configuring the Directive Scope

Directives share the scope with the parent by default. This is typically adequate for most needs. The biggest downside is that you might not want to include all the custom directive properties in the parent scope, especially if the parent scope is the root scope.

To solve that problem, you can define a separate scope for the directive using the scope property. The following sections describe how to add an inherited scope and an isolate scope.

Adding an Inherited Scope

The simplest method to add a scope to a directive is to create one that inherits from the parent scope. The advantage is that you have a scope separate from the parent to add additional values to, but the disadvantage is that the custom directives ...

Get Learning AngularJS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.