@Input is used to receive data in Angular 6, whereas @Output is used to send data outside. The output operator is used to send data out by exposing event producers, generally using the EventEmitter objects.

Here’s an example. Here there are 2 components, hello component nested inside the app component. The hello component here has an Input and an Output

hello.component.ts
  @Component({
  selector: 'hello',
  template: `
  <h3 (click)="onClick.emit('Yes')">
     ...
  </h3>
  `
})
export class HelloComponent {
   @Input() myContacts: string
   @Output() onClick = new EventEmitter()
}

 

It expects to receive a string value and then stores it in the myContacts property.

BY Best Interview Question ON 23 Feb 2020