【问题标题】:Manually insert Material Component inside Html Element在 Html 元素中手动插入 Material Component
【发布时间】:2019-03-11 23:33:59
【问题描述】:

如何在DivElement 中添加材料组件列表,例如MaterialCheckboxComponent

DivElement.childrenList<Element>,我看不到如何将List<MaterialCheckboxComponent> 转换为List<Element>

如何手动实现MaterialCheckboxComponent 的功能?

【问题讨论】:

    标签: dart angular-dart dart-html


    【解决方案1】:

    https://webdev.dartlang.org/angular/note/faq/component-loading是关于动态添加组件的部分

    @Component(
      selector: 'ad-view',
      template: r'''
        This component is sponsored by:
        <template #currentAd></template>
      ''',
    )
    class AdViewComponent {
      final ComponentLoader _loader;
    
      AdViewComponent(this._loader);
    
      @ViewChild('currentAd', read: ViewContainerRef)
      ViewContainerRef currentAd;
    
      @Input()
      set component(ComponentFactory component) {
        _loader.loadNextToLocation(component, currentAd);
      }
    }
    

    【讨论】:

    • 不,您可以直接删除强制添加的组件。
    • 我重写了我之前的评论(有一个错误,这里用粗体表示): 所以不可能从一个组件更新与模板组件相关的标签?例如类似的东西(不起作用): var target = querySelector('#target');目标.children.clear(); var listCheckBox = List (); 目标.children.add(listCheckBox);
    • 和以前一样的答案。
    • 我不确定你的意思是什么你只能强制删除强制添加的组件。。这里的“remove”是什么意思?因为我可以通过交换内容来更新StringSelectionOptions,而不是使用Imperative Component Loading 本身。
    • 好的,我猜对了。 感谢您的耐心等待。您将我引向正确的道路,但是我被这个写得不好的文档所困...
    猜你喜欢
    • 2017-02-27
    • 2011-06-16
    • 2020-05-20
    • 2022-07-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-14
    • 1970-01-01
    相关资源
    最近更新 更多