【发布时间】:2016-01-09 05:06:35
【问题描述】:
我正在尝试使用 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 所在的位置没有显示任何内容。不知道我哪里出错了。
【问题讨论】:
标签: javascript angularjs