且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

即时添加/删除组件

更新时间:2023-12-05 22:14:58

按照 Tim 的建议,

As suggested by Tim,

引用@tbosch 的评论

quoting @tbosch's comment

Angular 默认重用之前创建的 DOM 元素

Angular reuses previously created DOM elements by default

因此,为了避免这种行为,也从评论中获取,您可以使用 APP_VIEW_POOL_CAPACITY 并将其分配为 0 作为值.

So to avoid this behavior, taken from the comment as well, you can use APP_VIEW_POOL_CAPACITY and assign it 0 as value.

bootstrap(MyApp, [provide(APP_VIEW_POOL_CAPACITY, {useValue: 0})])

更新

请注意,由于 beta.1 APP_VIEW_POOL_CAPACITY 已被 #5993 和正在正确重新创建 DOM.

Update

Note that since beta.1 APP_VIEW_POOL_CAPACITY was removed by #5993 and the DOM is being recreated correctly.