我已经开始了一个
angularjs项目,我想实现fancybox.
为此,我将jQuery和fancybox插件包含在解决方案中.我试图在fancybox窗口中打开下面显示的代码中的模板.
视图
< a href =“”ng-click =“openPage('popups / add.html')”> ADD< / a>
调节器
app.controller('MainController',function MainController($scope) {
$scope.user = "hey Welcome";
$scope.open = function(template_path){
$.fancybox({"href":template_path})
}
}
)
和popup / add.html
<div class="pop-contnr">
<h2>ADD</h2>
<table>
<thead>
<tr>
<th align=center>{{user}}</th>
</tr>
</thead>
</table>
</div>
fancybox成功打开包含模板的窗口,但尚未评估{{user}}表达式.有人可以帮忙吗?
我为fancybox创建了一个指令
app.directive('fancybox',function($compile,$timeout){
return {
link: function($scope,element,attrs) {
element.fancybox({
hideOnOverlayClick:false,hideOnContentClick:false,enableEscapeButton:false,showNavArrows:false,onComplete: function(){
$timeout(function(){
$compile($("#fancybox-content"))($scope);
$scope.$apply();
$.fancybox.resize();
})
}
});
}
}
});