我正在尝试使用templateUrl来实现一个简单的指令,但到目前为止还没有成功。有人可以告诉我我错过了什么吗?
testing.html
<html ng-app="myApp">
<head>
<link rel="stylesheet" type="text/css" href="bootstrap.min.css" />
<script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script type="text/javascript" src="app.js"></script>
</head>
<body ng-controller="myCtrl as ctrl">
<test-directive></test-directive>
</body>
app.js
(function() {
var app = angular.module('myApp', []);
app.controller('myCtrl', function() {
});
app.directive("testDirective", function(){
return{
restrict: 'E',
templateUrl: "test-directive.html"
};
});
})();
测试directive.html
<p>this is a test directive</p>