Created
April 14, 2013 12:31
-
-
Save ysyun/5382540 to your computer and use it in GitHub Desktop.
AngularJS Local Scope Property Sample
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
/* | |
local scope property | |
<div ng-app="drinkApp"> | |
<div ng-controller="AppCtrl"> | |
<div drink flavor="strawberry"></div> | |
</div> | |
</div>*/ | |
var app = angular.module("drinkApp", []); | |
app.controller("AppCtrl", function($scope) { | |
$scope.ctrlFlavor = "blackberry"; | |
}) | |
app.directive("drink", function() { | |
return { | |
scope: { | |
flavor: "@" | |
}, | |
template: '<div>{{flavor}}</div>' | |
/* | |
scope: {flavor: "@"} | |
=== | |
link: function(scope, element, attrs) { | |
scope.flavor = attrs.flavor; | |
}*/ | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment