在我的指令:如何从指令数据传递给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