angularjs扩展指令配置-未定义指令
我正在阅读惊人的维基教程 我也试过了angularjs扩展指令配置-未定义指令,angularjs,angularjs-directive,Angularjs,Angularjs Directive,我正在阅读惊人的维基教程 我也试过了 var app = angular.module('myApp', []); app.controller('MainController',function() { }); app.directive('one', function() { return { template: '<div>I am one</div>', controller:function(){
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>' });
});
var-app=angular.module('myApp',[]);
app.controller('MainController',function(){
});
app.directive('one',function(){
返回{
模板:“我是一个”,
控制器:函数(){
},
链接:功能($scope){
}
};
});
app.directive('two',function(){
返回angular.extend({},oneDirective[0],{template:'I is two'});
});
但我有一个ReferenceError:oneDirective没有定义
请问怎么了?您忘记将第一个指令注入第二个指令:
app.directive('two', function(oneDirective) {
return angular.extend({}, oneDirective[0], { template: '<div>I am two</div>' });
});
app.directive('two',函数(oneDirective){
返回angular.extend({},oneDirective[0],{template:'I is two'});
});
oneDirective未在任何地方定义。