如何编译字符串html模板?

时间:2014-09-14 20:05:58

标签: twitter-bootstrap dart angular-dart

我正在尝试编译一个动态生成的字符串html模板,然后将带有正确绑定的编译输出插入到我的页面中。

我还没有找到在AngularDart 0.14.0中执行此操作的正确方法(版本之间有很多重大变化......)

这就是我所拥有的,但是template(childScope, childInjector, [inner])行无效并且期望DirectiveInjector我不知道如何

void onShadowRoot(Node shadowRoot) {
    Element tbody = pgtElement.querySelector(".pg-body");
    String html = '<tr ng-repeat="item in cmp.data">';
    for(PgTableColumnComponent td in this.tds){
        html += '<td>' + td.template + '</td>';
    }
    html += '</tr>';
    tbody.appendHtml(html);

    ViewFactory template = compiler([tbody], directives);
    Scope childScope = scope.createChild(scope.context);

    Injector childInjector = injector.createChild([new Module()..bind(Scope, toValue: childScope)]);
    Template(childScope, childInjector, [tbody]);
}

我也希望能够访问新编译代码中的组件范围,例如ng-repeat="item in cmp.data"

0 个答案:

没有答案