这就是我的js文件中的内容:
//classRelationship.directive.js
'use strict';
angular.module('app.class',[]).directive('classRelationship', function(){
return {
restrict: 'E',
template: 'I AM HERE'
};
});
angular.module('app.class',[]).controller('classRelationshipCtrl', ['$scope', function($scope){
console.info('test');
}]);这是我的html
// main.html
<div class="panel panel-default">
<div class="panel-heading"><span class="glyphicon glyphicon-th"></span> Manage Students</div>
<div class="panel-body">
<class-relationship></class-relationship>
</div>
</div>此时,I AM HERE不在html页面中出现,当我移除控制器或更改模块时,指令将被复制,我可以在html中看到模板文本,即
//classRelationship.directive.js
'use strict';
angular.module('app.class',[]).directive('classRelationship', function(){
return {
restrict: 'E',
template: 'I AM HERE'
};
});
angular.module('app.aNewModule',[]).controller('classRelationshipCtrl', ['$scope', function($scope){
console.info('test');
}]);我在js控制台上没有收到任何错误,也没有收到任何警告,也没有其他任何附加到该模块app.class的内容。知道为什么会这样吗?
发布于 2016-11-22 23:00:57
你给我打电话
angular.module('app.class',[])两次。
定义了模块,从而覆盖了先前定义的模块。
要使获得对先前定义的模块的引用,您需要在没有第二个数组参数的情况下使用该函数:
angular.module('app.class').controller(...https://stackoverflow.com/questions/40753207
复制相似问题