2015-09-09 63 views
-1

基本上,我有我的指令定義sample.js爲:AngularJS與腳本指令

app.directive('myDirective', function() { 
    return { 
     restrict: 'E', 
     scope: { 
      info: '=' 
     }, 
     templateUrl: 'link-to-sample.html' 
    }; 
}); 

在我sample.html我得到了(例如):

<script> 
    $(div).css('height', {{info}}+'px') //THIS DOESN'T WORK 
</script> 
<div></div> 

在我的說,index.html我想通過一個數值,通過info=''標記,並在腳本中使用它,運行在sample.html文件。

<my-directive info='100'></my-directive> 

但只使用{{info}}<script></script>標籤似乎不起作用。

如果你們幫我解決這個問題,我將不勝感激。


P.S.我知道,我可以在指令中編寫代碼,使用compiletemplate:,但我確實想保留在單獨的.html文件中。

+2

我想你可以代碼''