【发布时间】:2013-07-06 01:42:00
【问题描述】:
我正在尝试使用 ui-bootstrap 模态创建可重复使用的指令。
除了选项外,它几乎可以工作
这里是指令:
directive('update', function() {
return {
restrict: "E",
templateUrl: "tplModal.html",
scope: {
selected:"="
},
link: function(scope, elm, attr){
scope.open = function (obj) {
scope.shouldBeOpen = true;
};
scope.close = function () {
scope.shouldBeOpen = false;
};
scope.opts = {
backdropFade: true,
dialogFade:true
};
}
}
})
和 tplModal.html
<button class='btn' ng-click='open(selected)'>Update</button>
<div modal="shouldBeOpen" close="close()" options="opts">
<div class="modal-header">
<h3><i class="lead" icon="{{selected.type}}"></i> {{selected.name}}</h3>
</div>
<div class="modal-body">
<!-- stuffs here -->
</div>
<div class="modal-footer">
<button class="btn btn-warning cancel" ng-click="close()">Cancel</button>
</div>
</div>
尽管有scope.opts,但没有淡入淡出效果。
这是整个代码: http://plnkr.co/edit/Ab4BOH?p=preview
我做错了什么?
【问题讨论】:
-
在这里发布代码,告诉你如何使用指令,告诉你期望代码做什么,以及它做什么。
-
我更新了问题
-
您的 plunk 不起作用,我收到“Plunk not found”错误。
-
贴出tplModal.html的代码
-
对不起。我更新了问题,plnkr 的链接正在运行
标签: angularjs angular-ui-bootstrap