Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <h4>Passing value of input element to child component:</h4>
- <input [ngModel]="name" (ngModelChange)="name = $event">
- <p>{{name}}</p>
- <hello [name]="name"></hello>
- @Component({
- selector: 'my-app',
- templateUrl: './app.component.html',
- styleUrls: [ './app.component.css' ]
- })
- export class AppComponent {
- name = '';
- }
- @Component({
- selector: 'hello',
- template: `<h4>Passed : "{{ name }}" to child component!</h4>`,
- styles: [`h1 { font-family: Lato; }`]
- })
- export class HelloComponent {
- @Input() name: string;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement