2017-02-05 4 views
0

このようなapp.jsのようなメニュー指示を作成しました。指令は次のようにインデックスページで使用されているangularjsのコントローラの作成方法

.directive('menuShow', function() { 
     return { 
      restrict: 'EA', 
      templateUrl: 'shared/menu.html', 
     } 
    }); 

:今

<menu-show ></menu-show> 

、私はmenu.htmlディレクティブで使用される機能のコードを書きたいです。

menu.htmlのコントローラの書き込み方法。

答えて

1

あなたのディレクティブのコントローラを作成し、ディレクティブでこれを設定することができ、

.directive('menuShow', function() { 
     return { 
      restrict: 'EA', 
      templateUrl: 'shared/menu.html', 
      controller: menuCtrl, 
      controllerAs: 'test', 
      bindToController: true 
     } 
    }); 
関連する問題