Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement