1
我是AngularJs的新手。我試圖調用自定義指令,但它沒有被調用。AngularJs自定義指令沒有被調用
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script src="customDirective.js"></script>
</head>
<body>
<div ng-app="app">
<div ng-controller="MyController as ctrl">
<testingDirective></testingDirective>
{{ctrl.test}}
</div>
</div>
</body>
我的JavaScript文件看起來像:
var app=angular.module('app',[]);
app.controller('MyController',[function(){
var self=this;
self.test='no';
}]);
app.directive('testingDirective',function(){
return{
restrict:'AE',
replace:true,
template:'<h1>Hello World Test</h1>'
};
});
@Shreyas感謝它與 –
一起工作謝謝我沒有意識到駱駝案件指令名稱 –