0
我想了解有關角度指令並遵循這裏給出的例子(http://docs.angularjs.org/guide/directive),寫下了下面的代碼。任何人都可以請指導我,因爲我做錯了,控制器範圍內的數據沒有在指令中讀取?該網站一無所知!執行代碼時沒有錯誤,它只是不顯示任何數據。請幫忙。AngularJS指令不從控制器讀取數據
//My Html
<!DOCTYPE html>
<html data-ng-app="MyApp">
<head>
<title>Angular Directives</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body >
<div data-ng-controller = "MyCtrl"></div>
<div data-template-expanding-directive></div>
<script src="lib/angular.js"></script>
<script src="js/templateExpandingDirective.js"></script>
</body>
</html>
//My JS
'use strict';
var myapp = angular.module('MyApp',[]);
myapp.controller('MyCtrl',['$scope',function($scope){
$scope.customer = {
name: "Jenny",
place: "England"
};
}])
.directive('templateExpandingDirective',function(){
return {
template: 'Name: {{customer.name}}'
};
});
問候
哦,我的壞!非常感謝! – 5122014009