在我的指令:如何從指令數據傳遞給HTML模板 - AngularJS
angular.module('myPopUp',[])
.directive('myPopUp',['$document', function($document){
return{
restrict: 'EA',
controller: function($scope){
},
scope: {
},
templateUrl: 'popup.html',
link: function(scope, elm, attr){
var topPosition = top + (btnHeight/2) - (popOverHeight/2);
}
在做鏈接的計算後,如何可以通過「topPosition」我popup.html模板?有任何想法嗎?
我嘗試這樣做,但它不起作用。
popup.html:
<div class="popover right" style="width:auto;top:{{topPosition}}px;">
<div class="arrow"></div>
<div>.......</div>
</div>
感謝您的回答,但它仍然無法正常工作。我錯過了什麼?我曾嘗試添加 範圍:topPosition:'@' }, 但仍不能正常工作....任何想法? – user2991183
@ user2991183更新並附帶演示鏈接 – sol4me