ngmodel component angular 1

ngmodel component angular

import { Component, OnInit, Output, Input, EventEmitter } from '@angular/core';

@Component({
  selector: 'app-input',
  template: `  `,
  styleUrls: ['./app-input.component.scss']
})
export class AppInputComponent {
  @Input() inputModel: string;
  @Output() inputModelChange = new EventEmitter();
}

Here is what the above code is Doing:
1. We have a component called AppInputComponent.
2. It has an input property called inputModel.
3. It has an output property called inputModelChange.
4. The input property is bound to the input element’s ngModel property.
5. The output property is bound to the input element’s ngModelChange event.
6. The input property is bound to the output property.

Now, let’s see how we can use this component in our app.component.html file:

Similar Posts