[英]Re $compile angular directive?
好的,我有一個使用angular-meteor的Meteor應用程序,我使用blaze通過textAngular將模板添加到自動表單中,這只是一個簡單的angular指令,
更新表單后,Meteor / Blaze / Autoform會以程序方式重新呈現該表單,這反過來又從我的自定義指令中剝奪了范圍。
Autoforms重新呈現表單后,如何重新呈現有角的“ textAngular”指令?
我假設我應該使用Template.NAME.rendered
事件,在重新渲染后調用它可以正常工作,但是如何強制angular重新編譯指令?
你可以找到整個包在這里和我在rerenderign特別是企圖在這里
任何幫助都非常感謝!
克里斯
好的,我已經這樣做了:
Template.autoFormTextAngular.rendered = function () {
if(!$(this.firstNode).hasClass('ta-root')){
// create an injector
var $injector = angular.injector(['ng', 'textAngular']);
// use the injector to kick off your application
// use the type inference to auto inject arguments, or use implicit injection
$injector.invoke(function($rootScope, $compile, $document) {
$compile($document)($rootScope);
$rootScope.$digest();
});
}
};
不知道是否有更簡單的方法,但是嘿,它是否有效...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.