我正在尝试使用角度种子项目(https://github.com/angular/angular-seed https://github.com/angular/angular-seed)开始一个新项目。我正在尝试添加一个新指令。
创建了 testDirective.js 文件:
'use strict';
angular.module("myApp.testDirective", [])
.directive("testDirective",
function() {
return {
template : "<h1>Made by a directive!</h1>"
};
});
将文件包含在index.html中,将“myApp.testDirective”添加到app.js中,在view1.js中我添加了:
'use strict';
angular.module('myApp.view1', ['ngRoute','myApp.testDirective'])
.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/view1', {
templateUrl: 'view1/view1.html',
controller: 'View1Ctrl'
});
}])
.controller('View1Ctrl', [function() {
}]);
view1.html 看起来像:
<p>This is the partial for view 1.</p>
<div testDirective></div>
但是,当我运行该应用程序时,testDirective 所在的位置没有显示任何内容。不知道我哪里出错了。