Syntax for using angular 2 components inside angular 1 views.
Using ng-upgrade we can downgrade angular 2 components and services and use those inside our existing angular 1 app, before that we need to make changes.
There are excellent documentation on how to configure our existing application to do that, but once we have it running there are several things that we need to figure out.
TL;DR
- use ng2 notation for model and event bindings, such as () [] or [()]
- use ng1 notation (kebab-casing) for input or output variables, so if we declare @Input() parameterId, we should pass it over as [parameter-id]
- bindings from ng1 controller use ng1 naming, i.e. if using controllerAs syntax, [parameter-id]=”vm.parameterId” or (on-custom-event)=”vm.doSomething()”
Model Binding
We know that in angular2, property bindings are done through [attr.title] while event bindings are (click), lastly for two-way bindings, we can do a [(ngModel)] or banana-in-a-box. These are different in angular 1.x where we use specific directives, such as ng-model, ng-click, ng-value …
TO be continued…