最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to use an AngularJS 2 component multiple times in the same page? - Stack Overflow

programmeradmin0浏览0评论

After declaring a ponent with selector 'some-p', using <some-p></some-p> in a page will only work once. I would like to use it multiple times any help, here is an example code:

@Component({ selector: 'some-p' })
@View({ template: 'ponent template' })
class SomeComponent {    }
bootstrap(SomeComponent);

After declaring a ponent with selector 'some-p', using <some-p></some-p> in a page will only work once. I would like to use it multiple times any help, here is an example code:

@Component({ selector: 'some-p' })
@View({ template: 'ponent template' })
class SomeComponent {    }
bootstrap(SomeComponent);
Share Improve this question edited Aug 13, 2018 at 4:20 user6749601 asked Jun 12, 2015 at 16:26 Oussama GammoudiOussama Gammoudi 7617 silver badges14 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

The bootstrapped Component is really to be looked at as an app, if you want to use the same ponent multiple times, you will want to make it into a directive and then include that directive in your app which you bootstrap.

Look at this menu ponent as an example, you will see the <aria-menuitem> ponents used multiple times as well as the <aria-menu> ponents.

https://github./dylanb/Axponents/tree/master/angular2

发布评论

评论列表(0)

  1. 暂无评论