when I use '=' to pass a function, it works fine. But why the '&' exsits? Is it just let it look like an event?
Asked
Active
Viewed 59 times
1 Answers
1
Attribute's interpolation: @
@
indicates to AngularJS that should interpolate the value of the specified attribute (the value in the isolated scope changes if the attribute's value changes).
Binding data to the attribute: =
=
indicates to AngularJS that should keep the expression of the specified attribute (the value in the isolated scope changes if the attribute's expression changes).
Providing a callback: &
&
indicates to AngularJS that the expression specified in the attribute will be avaliable on the isolated scope as a function that will execute the expression. Use this option to create callbacks.
-
-
I think no. But if you need to use variables from parent scope is simpler passing only a callback function (using `&`) that passing the function and all the variables that you need to directive (using `=`). http://codepen.io/ces/pen/xGOLdg – cespon May 18 '15 at 08:56
-
You have more examples and information here: http://stackoverflow.com/questions/14050195/what-is-the-difference-between-and-in-directive-scope – cespon May 18 '15 at 09:05