我正在阅读令人惊叹的维基教程 https://github.com/angular/angular.js/wiki/Understanding-Directives#specialized-the-directive-configuration
我尝试过像
var app = angular.module('myApp', []);
app.controller('MainController',function() {
});
app.directive('one', function() {
return {
template: '<div>I am one</div>',
controller:function(){
},
link:function($scope){
}
};
});
app.directive('two', function() {
return angular.extend({}, oneDirective[0], { template: '<div>I am two</div>' });
});
但我有ReferenceError:oneDirective未定义
那怎么回事,拜托?
答案 0 :(得分:0)
您忘了将第一个指令注入第二个指令:
app.directive('two', function(oneDirective) {
return angular.extend({}, oneDirective[0], { template: '<div>I am two</div>' });
});