我已經嘗試了一個基本的angularjs應用程序。我的控制器工作正常,但指令中的模板似乎不起作用,請提出解決方案。爲什麼Angularjs指令模板不能渲染?
下面是我的代碼
的index.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" data-ng-app="DataApp1">
<head>
<script src="Scripts/angular.min.js"></script>
</head>
<body>
<div data-ng-controller="DataController1">
<data-directive> </data-directive>
</div>
<script src="Scripts/App.js"></script>
</body>
</html>
app.js
/// <reference path="angular.js" />
var myapp = angular.module("DataApp1", []);
myapp.controller("DataController1", function ($scope) {
});
myapp.directive("dataDirective", function() {
return {
restrict: 'E',
template: '<h2>Hi</h2>'
};
});
好,我知道它但錯誤:)感謝您的答案:) – NewDirection