Search code examples
javascriptangularjsangulartypescriptangular-upgrade

Can you use Angular 1 views in an Angular 2 app?


I am working on an app written in Angular 2, and we have many views that are written in Angular 1 from another application that we would like to use in our Angular 2 app with some minor changes. Is this possible? I've looked into this a little bit and read some tutorials but they all seem based on upgrading an Angular 1 project to Angular 2, not using Angular 1 in an existing Angular 2 project. Would I need to rewrite my app.module.ts and my route file in Angular 1 in order to achieve this and if so are there any other file I would need to rewrite?


Solution

  • Yes, you can. Basic Angular Directives such as ng-click are not changed, but the behavior of Two-ways data binding is changed. But you can be able to migrate with some minor changes in you view.

    Somehow, you will be face some amount of refactoring from your Angular 1 JavaScript to Angular2 TypeScript and for that you will need to rewrite some of your codes like routes when you migrate your app. But there's a lot of references for migration. Check it out the following link.

    https://www.codementor.io/angularjs/tutorial/migrating-from-angular-1-to-angular-2

    Regards.