Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinchisholm/b7713c96f056238e47c3fc27f3764c1d to your computer and use it in GitHub Desktop.
Save kevinchisholm/b7713c96f056238e47c3fc27f3764c1d to your computer and use it in GitHub Desktop.
import {Component, Input } from '@angular/core';
@Component({
selector: 'child1',
templateUrl: 'src/child1/child1.html',
})
export class Child1Component {
@Input() userNameFromParent = '';
@Input() userPhoneFromParent = '';
}
<strong>Name: </strong> {{userNameFromParent}}
<strong>Phone: </strong> {{userPhoneFromParent}}
import { Component, Input } from '@angular/core';
@Component({
selector: 'child2',
templateUrl: 'src/child2/child2.html'
})
export class Child2Component {
@Input('theUserName') name = '';
@Input('thePhone') phone = '';
}
<strong>Name: </strong> {{name}}
<strong>Phone: </strong> {{phone}}
import { Component } from '@angular/core';
@Component({
selector: 'parent',
templateUrl: 'src/parent/parent.html'
})
export class ParentComponent {
public userName = '';
public userPhone = '';
}
<input
type="text"
[(ngModel)]="userName"
placeholder="Enter user name here">
<input
type="text"
[(ngModel)]="userPhone"
placeholder="Enter user phone number here">
<child1
userNameFromParent="{{userName}}"
userPhoneFromParent="{{userPhone}}"></child1>
<child2
theUserName="{{userName}}"
thePhone="{{userPhone}}"></child2>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment