The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Isolate Scope "&"

Isolate Scope "&"

6:03
The "&" in your isolated scopes within your AngularJS application will allow you to invoke a method within the scope that your directive lives in.
Watch this lesson now
Avatar
egghead.io

The "&" in your isolated scopes within your AngularJS application will allow you to invoke a method within the scope that your directive lives in.

Avatar
glasson

hi, what does the "message" parameter in the html code refers to? Is it a dummy variable? Does it bind to the first part of the expression "message:value" contained in the js-file? If yes, does it mean that the use of the directive in html pre-supposes knowing the name of the parameters define in the template? Or can I use another name?

In reply to egghead.io
Avatar
Eric

+1 to the earlier question - I'm trying to call a function being passed into my directive, and am unable to get things to work quite correctly.

See also my SO question here http://stackoverflow.com/questions/23548746/angular-isolate-scope-attribute-behaviors

Is there documentation on this somewhere you can recommend? It's all very vague on the angular documentation site.

Avatar
Joel

Basically you can think of it in terms of dependency injection and a named parameter where dial({message:value}) is specifying the value of that parameter. The hash in the dial call needs to contain a message property, and that message property's value will be supplied.

Frankly, I think this is weird, and personally prefer to user a service I've created or = object binding to accomplish this wort of thing.

In reply to Eric
Avatar
mike connor

if found there was a problem with the controller until i listed '$scope' in the array that is the 2nd parameter of controller. Like this:

.controller('PhoneCtrl', ['$scope', function ($scope) {

$scope.callHome = function (msg) {
        alert(msg);
    };
}])
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?