Angular: Directive Scope Binding
http://angularjs.org/
by HyunSeob Lee
HTML
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
<div ng-controller="myCtrl">
{{ data }}
<my-directive></my-directive>
</div>
CSS
div {
color: white;
}
JavaScript
var myApp = angular.module('myApp', []);
myApp.controller('myCtrl', ['$scope', function ($scope) {
$scope.data = 'AAA';
}]);
myApp.directive('myDirective', function() {
return {
restrict: 'E',
scope: false,
template: '<div>{{data}}</div>',
link: function(scope) {
scope.data = 'BBB';
}
}
});