I am currently using the @Input on my child component, and passing in one variable, but I can't figure out how to pass in a second one.
-
1...add another input?jonrsharpe– jonrsharpe2016-12-20 20:56:08 +00:00Commented Dec 20, 2016 at 20:56
-
@jonrsharpe or objectyurzui– yurzui2016-12-20 20:58:49 +00:00Commented Dec 20, 2016 at 20:58
-
1Oh my god :( , this killed meMilad– Milad2016-12-20 21:00:49 +00:00Commented Dec 20, 2016 at 21:00
Add a comment
|
2 Answers
Alternatively, See this : https://stackblitz.com/edit/angular-with-multiple-variable-input
You can pass all your variable as Object:
In Parent
/* parent.component.ts file */
export class ParentComponent{
parentVariables:Object = {
variable1 : "Temp String",
variable2 : 23 // Temp Number
}
}
<!-- parent.component.html file -->
<app-child [childVariables]="parentVariables"> </app-child>
In Child
/* child.component.ts file */
export class ChildComponent{
@Input()
childVariables:any;
}
<!-- child.component.html file -->
variable1 : {{childVariables.variable1}} <br />
variable2 : {{childVariables.variable2 }}