2016-11-17 88 views
0

有两个指令。一个是 “伪指令”指令,要求,角js

主要:

.directive('materialDropdown', function() { 
    // Input to directive 
    return { 
     scope: { 
     //'personalDb': '=', 
     }, 
     transclude: true, 
     controllerAs: 'vm', 
     bindToController: true, 
     controller: function(){ 
     console.log('material directive fires') 

     }, 
     template: '<select></select>', 
     restrict: 'E', 
     link: function(){} 
    }; 

});

子:

.directive('materialSizeDropdown', function() { 
    // Input to directive 
    return { 
     require: '^^materialDropdown', 
     controllerAs: 'vm', 
     transclude: true, 
     bindToController: true, 
     controller: function(){ 
     console.log('hello') 
     }, 
     template: '<h1>fire</h1>', 
     restrict: 'E', 
     link: function(){} 
    }; 

标记:

<material-dropdown> 
    <material-size-dropdown></material-size-dropdown> 
    </material-dropdown> 

的materialSizeDropdown未在标记示出,并且所述控制器被也不烧制。

我该如何解决这个问题?

+0

我还没有使用过我自己的指令,但是在你的要求中只需要使用'materialDropdown'而不是'^^ materialDropdown'。 –

回答

0

您正在materialDropdown指令中使用template选项,该指令将用于渲染。所以你的嵌套指令将永远不会显示。而<h1><select>将无效。