4 ms·
Can anyone comment on Angular 1 and Angular 2 living side by side in the same project, for the purposes of slowly migrating over to 2? I am aware that it is po
by nsxwolf 10y ago
Can anyone comment on Angular 1 and Angular 2 living side by side in the same project, for the purposes of slowly migrating over to 2?
I am aware that it is possible, but I've yet to read anything about someone really living with that. Everyone just talks about rewriting all code from scratch, which we're just not going to do.
- ben_jones 10y agoAngular 1.x yields pretty well to ES6 (classes and so forth) which can have your angular 1.x project looking similar to 2.x, at least for controller definitions. This is a good example [1] and the somewhat equivalent ng2 example (with extraneous TS stuff) [2]. Both those projects are also good examples of Angular1/2 conventions like having an imports folder, api/ui separation of concernts, and so forth. [1]: https://github.com/Urigo/meteor-angular-socially/blob/step_16/imports/ui/components/partiesList/partiesList.js https://github.com/Urigo/meteor-angular-socially/blob/step_1... [2]: https://github.com/Urigo/meteor-angular2.0-socially/blob/step_16/client/imports/app/parties/parties-list.component.ts https://github.com/Urigo/meteor-angular2.0-socially/blob/ste... IMO neither of those examples are good benchmarks for Angular 1 or 2 because they have boilerplate for interop with MeteorJS. Plain Angular2 is much cleaner FWIW.
- livingparadox 10y agoI'm actually migrating a large (poorly written) angular 1 project to angular 2 using the adapter. For the most part, its pretty straightforward. Unfortunately, if your ng1 code still uses ng-controller extensively, you'll probably be stuck at the rc4 release of Angular 2. Everytime I've tried to upgrade past that point, none of the controllers initialize. Aside from that and the inability to mix attributes and directives from different versions, I haven't really dealt with any major problem upgrading. For any services you have which are returning promises instead of observables, I highly recommend creating a re-usable adapter class as it allows you to drop-in replace legacy implementations with new observable based services without changing the consuming ng1 code.