2015-12-21 122 views
0

我創建angularjs指令:與angularJs指令問題

'use strict'; 

angular.module('frontend') 
    .directive('overall', function() { 
     return { 
      restrict: 'E', 
      scope: { 
       data: '=data' 
      }, 
      templateUrl: 'app/components/overall/overall.html', 
      controller: function($scope) { 
       alert($scope.data) 
      } 
     }; 
    }); 

和模板是爲他

<div id="inner-overall"> 
    Taras 
</div> 

它之後在其他頁我用我的指示是這樣的:

<overall data></overall> 

和js代碼:

$scope.data = 'daadad'; 

但它不工作,我趕上空的$ scope.data值。 我不知道爲什麼會發生,以及如何解決它,請幫助我解決這個問題。非常感謝!

回答

3

你不綁定模式,這就是爲什麼它是空

試試這個

<overall data="data"></overall> 
+0

非常感謝,這是我的固定的問題等。 –

+0

@TarasKovalenko歡迎您:)請標記接受:) –