我已經開始了一個angularjs項目,並且我想實現fancybox。AngularJS Fancybox Popup
爲此,我將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})
}
}
)
而且彈出/ add.html
<div class="pop-contnr">
<h2>ADD</h2>
<table>
<thead>
<tr>
<th align=center>{{user}}</th>
</tr>
</thead>
</table>
</div>
Fancybox成功打開一個包含模板的窗口,但尚未評估{{user}}
表達式。任何人都可以幫忙嗎?
我不想在每次單擊元素時加載模板 - 是否有任何可加載的模板只能加載一次? – Tony
好東西,非常感謝!看起來像Angular的內部模板加載器(在指令中)有問題在初始化時被fancybox識別出來......這種方法保證模板真的存在。 – Alex
@Tony - 瀏覽器將緩存模板,因此將保存HTTP往返。 – Alex