Angular 6 : Parent and Child component
Here is sample code, how to use parent and child component in angularjs 6.
Model Class
export class country{
ID : number;
Name : string;
}
Parent Component
name : string = "DemoName";
vmCountry : country;
constructor() { }
ngOnInit() {
this.vmCountry = new country();
this.vmCountry.Name = "India";
}
<div>
Some html here
</div>
<app-child [name]="name" [varCountry]="vmCountry"></app-child>
<div>
Some html here
</div>
"expression": {
"and": [
{
"equals": [
"@outputs('HttpStepName')['body']?['ResultCode']",
"OK"
]
}
]
},
Child Component
@Input() name : string;
@Input() varCountry:country;
constructor() { }
ngOnInit() {
}
<p>
child works {{name}}!
</p>
<h1>{{varCountry.Name}}</h1>
app.module.ts
@NgModule({
declarations: [
....
ParentComponent,
ChildComponent
],
.....
})
Hope this will help you and save your time.
Enjoy !!!
:)
No comments:
Post a Comment