setInnerHtml不评估小胡子 [英] setInnerHtml doesn't evaluate Mustache

查看:119
本文介绍了setInnerHtml不评估小胡子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我添加了一些HTML内容,在我的NgComponent中添加了setInnerHtml()。



日志显示,指令被实例化,但 {{ctrl.xxx }} 表达式。



为了设置HTML,我使用一个指令派生形式 ng-bind-html 与自定义 NodeValidator 和以下 code>方法。

  ){
_element.setInnerHtml((value == null?'':value.toString()),
validator:validator);
_log.finest(value);
if(value!= null){
BlockFactory template = _compiler(_element.children,_directiveMap);
块块= template.bind(_injector)(_ scope);
}
}

我也有一些 ; input type ='text'ng-model ='ctrl.someValue'>
调试器显示ng-model被实例化,并且

getter ctrl.someValue 被调用

,但是输入元素不显示返回值。



当我将生成的HTML静态地插入 template

解决方案



如何获得Angular完全处理的动态插入HTML。

EDIT



http://pub.dartlang.org/packages/bwu_angular 将此装饰/指令包含为 bwu-safe-html



------



我发现解决方案此处



<
设置值(值){
if(value == null)如果没有设置值, {
_element.nodes.clear();
return;
}
_element.setInnerHtml((value == null?'':value.toString()),
validator:validator);
_log.finest(value);
if(value!= null){
_compiler(_element.childNodes,_directiveMap)(_ injector,_element.childNodes);
}
}

请参阅我对如何在Angular.Dart中以编程方式添加组件?获取完整代码


I add some HTML content adding setInnerHtml() inside my NgComponent.

Logging shows, that directives are instantiated but {{ctrl.xxx}} expressions are not evaluated.

For setting the HTML I use a directive derived form ng-bind-html with a custom NodeValidator and the following value method.

  set value(value) {
    _element.setInnerHtml((value == null ? '' : value.toString()),
                                             validator: validator);
    _log.finest(value);
    if(value != null) {
      BlockFactory template = _compiler(_element.children, _directiveMap);
      Block block = template.bind(_injector)(_scope);
    }
  }

I have also some <input type='text' ng-model='ctrl.someValue'> in the inserted HTML. The debugger shows that the ng-model is instantiated and
the getter ctrl.someValue gets called
but the input element doesn't show the returned value.

When I insert the generated HTML statically as template all works fine.

How can get dynamically inserted HTML fully processed by Angular.

解决方案

EDIT

The package http://pub.dartlang.org/packages/bwu_angular contains this decorator/directive as bwu-safe-html

------

I found the solution here

  @NgOneWay('ac-bind-html')
  set value(value) {
    if(value == null) {
      _element.nodes.clear();
      return;
    }
    _element.setInnerHtml((value == null ? '' : value.toString()),
                                             validator: validator);
    _log.finest(value);
    if(value != null) {
      _compiler(_element.childNodes, _directiveMap)(_injector, _element.childNodes);
    }
  }

see also my answer on How to add a component programatically in Angular.Dart? for the full code

这篇关于setInnerHtml不评估小胡子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆