Isolate Scope "&"

Share this video with your friends

Send Tweet

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

Eric
Eric
~ 10 years ago

+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.

Joel Hooks
Joel Hooks
~ 10 years ago

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.

mike connor
mike connor
~ 8 years ago

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);
    };
}])