Last active
January 5, 2018 09:49
-
-
Save kevinchisholm/4b968b4f930698a2f597b6b6b6eaffaa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; | |
@Component({ | |
selector: 'child1', | |
templateUrl: 'src/child1/child1.html', | |
}) | |
export class Child1Component { | |
userInfo: any = { | |
name: '', | |
phone: '' | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<label>User Name</label> | |
<input | |
type="text" | |
[(ngModel)]="userInfo.name" | |
placeholder="Enter user name here"> | |
<label>User Phone Number</label> | |
<input | |
type="text" | |
[(ngModel)]="userInfo.phone" | |
placeholder="Enter user phone number here"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; | |
@Component({ | |
selector: 'child2', | |
templateUrl: 'src/child2/child2.html' | |
}) | |
export class Child2Component { | |
userInfo: any = { | |
name: '', | |
phone: '' | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<label>User Name</label> | |
<input | |
type="text" | |
[(ngModel)]="userInfo.name" | |
placeholder="Enter user name here"> | |
<label>User Phone Number</label> | |
<input | |
type="text" | |
[(ngModel)]="userInfo.phone" | |
placeholder="Enter user phone number here"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, ViewChild, AfterViewInit } from '@angular/core'; | |
import {Child1Component} from '../child1/child1.component' | |
import {Child2Component} from '../child2/child2.component' | |
@Component({ | |
selector: 'parent', | |
templateUrl: 'src/parent/parent.html' | |
}) | |
export class ParentComponent { | |
@ViewChild(Child1Component) child1: Child1Component; | |
@ViewChild(Child2Component) child2: Child1Component; | |
userInfo1: any = { | |
name: '', | |
phone: '' | |
}; | |
userInfo2: any = { | |
name: '', | |
phone: '' | |
}; | |
ngAfterViewInit() { | |
this.userInfo1 = this.child1.userInfo; | |
this.userInfo2 = this.child2.userInfo; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h2>Data From Child 1</h2> | |
<strong>Name: </strong> {{userInfo1.name}} | |
<strong>Phone: </strong> {{userInfo1.phone}} | |
<h2>Data From Child 2</h2> | |
<strong>Name: </strong> {{userInfo2.name}} | |
<strong>Phone: </strong> {{userInfo2.phone}} | |
<child1></child1> | |
<child2></child2> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment