Created
April 14, 2013 12:57
-
-
Save ysyun/5382630 to your computer and use it in GitHub Desktop.
AngularJS & scope send local property to parent scope
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
& scope | |
<div ng-app="phoneApp"> | |
<div ng-controller="AppCtrl"> | |
<div phone dial="callHome(message)"></div> | |
<div phone dial="callHome(message)"></div> | |
</div> | |
</div> | |
*/ | |
var app = angular.module("phoneApp", []); | |
app.controller("AppCtrl", function($scope) { | |
$scope.callHome = function(message) { | |
alert(message); | |
} | |
}) | |
app.directive("phone", function() { | |
return { | |
scope: { | |
dial: "&" | |
}, | |
template: '<input type="text" ng-model="value">' + | |
'<div class="button" ng-click="dial({message:value})">Call Home</div> ' | |
} | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment