Re $编译angular指令?

时间:2015-08-26 23:18:31

标签: javascript angularjs meteor angular-meteor

好的我有一个使用角度流星的Meteor应用程序,我使用blaze将模板添加到autoform使用textAngular,这只是一个简单的角度指令,

更新表单后,Meteor / Blaze / Autoform将以编程方式呈现表单,然后从我的自定义指令中删除范围。

在Autoforms重新呈现表单后,如何重新呈现角度'textAngular'指令?

我假设我应该使用Template.NAME.rendered事件,它在重新渲染后调用正常但是如何强制角度重新编译指令?

您可以找到整个包here以及我特别尝试重新签名here

任何帮助都很受欢迎!

克里斯

1 个答案:

答案 0 :(得分:0)

好的我已经这样做了:

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();
    });
  }

};

不确定是否有更简单的方法但是嘿它有效...