SHARE
TWEET

Untitled

a guest Aug 20th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <h4>Passing value of input element to child component:</h4>
  2. <input [ngModel]="name" (ngModelChange)="name = $event">
  3. <p>{{name}}</p>
  4. <hello [name]="name"></hello>
  5.      
  6. @Component({
  7.   selector: 'my-app',
  8.   templateUrl: './app.component.html',
  9.   styleUrls: [ './app.component.css' ]
  10. })
  11. export class AppComponent  {
  12.   name = '';
  13. }
  14.      
  15. @Component({
  16.   selector: 'hello',
  17.   template: `<h4>Passed : "{{ name }}" to child component!</h4>`,
  18.   styles: [`h1 { font-family: Lato; }`]
  19. })
  20. export class HelloComponent  {
  21.   @Input() name: string;
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top