Use AngularJS (Angular1) module from Angular2 project

前端 未结 2 1663
无人及你
无人及你 2021-02-05 19:21

Just started a demo Angular2 project (no previous experience with Angular1/AngularJS. Have followed and extended from the online quickstart and tutorials, and all was fine. Howe

2条回答
  •  长情又很酷
    2021-02-05 20:08

    Here is a working plunkr describing how to mix Angular1 and Angular2 elements:

    • http://plnkr.co/edit/yMjghOFhFWuY8G1fVIEg?p=preview

    An important point is to bootstrap your main component on the UpgradeAdapter. This way all elements are available in providers (services / factories) and in directives (components / directives):

    upgrade.bootstrap(document.body, ['heroApp']);
    

    These two answers could help you:

    • angular 1.x and angular2 together
    • How to inject upgraded Angular 1 service/factory to Angular 2 component in ES5?

提交回复
热议问题