0
我已經爲'Celebrity Name'做了一個簡單的Angular.js指令。我正在閱讀有關隔離示波器@,&,=,但我不知道如何在以下簡單示例中使用它們來了解它們的用法和差異。有人可以幫我嗎?使用隔離範圍 - @,&和=在一個簡單的Angular指令中
HTML:
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
<celebrity></celebrity>
<celebrity></celebrity>
<celebrity></celebrity>
<script>
//defining module
var app = angular.module('myApp',[]);
//defning Controller
app.controller('myCtrl',function($scope){
$scope.name = "Brad Pitt";
});
//defining directive
app.directive('celebrity',function(){
return{
restrict: 'E',
scope: {},
template: '<div>{{name}}</div>'
}
});
</script>
</body>
</html>
結果:
Currently all my 3 instances of directive 'celebrity' print 'Brad Pitt'.
請,有人告訴我如何使用3種類型的分離範圍,在這個簡單的例子。