Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 45304a9

Browse files
bradw2kcaitp
authored andcommitted
docs(guide/directive): add a more detailed description of isolate scope & bindings
More description of "&" bindings, the fact that they trigger evaluation of expressions in the original scope's context. Closes #6255
1 parent 0478bb4 commit 45304a9

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

docs/content/guide/directive.ngdoc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -736,9 +736,14 @@ We want to run the function we pass by invoking it from the directive's scope, b
736736
in the context of the scope where its registered.
737737

738738
We saw earlier how to use `=attr` in the `scope` option, but in the above example, we're using
739-
`&attr` instead. `&` bindings expose a function to an isolated scope allowing the isolated scope
740-
to invoke it, but maintaining the original scope of the function. So when a user clicks the
741-
`x` in the dialog, it runs `Ctrl`'s `hideDialog` function.
739+
`&attr` instead. The `&` binding allows a directive to trigger evaluation of an expression in
740+
the context of the original scope, at a specific time. Any legal expression is allowed, including
741+
an expression which contains a function call. Because of this, `&` bindings are ideal for binding
742+
callback functions to directive behaviors.
743+
744+
When the user clicks the `x` in the dialog, the directive's `close` function is called, thanks to
745+
`ng-click.` This call to `close` on the isolated scope actually evaluates the expression
746+
`hideDialog()` in the context of the original scope, thus running `Ctrl`'s `hideDialog` function.
742747

743748
<div class="alert alert-success">
744749
**Best Practice:** use `&attr` in the `scope` option when you want your directive

0 commit comments

Comments
 (0)