“saída angular” Respostas de código

Enviar evento para o componente filho angular

Parent-Component

eventsSubject: Subject<void> = new Subject<void>();

emitEventToChild() {
  this.eventsSubject.next();
}


Parent-HTML

<child [events]="eventsSubject.asObservable()"> </child>


Child-Component

private eventsSubscription: Subscription;

@Input() events: Observable<void>;

ngOnInit(){
  this.eventsSubscription = this.events.subscribe(() => doSomething());
}

ngOnDestroy() {
  this.eventsSubscription.unsubscribe();
}
Coding is simple XD

saída angular

content_copy
export class ItemOutputComponent {

  @Output() newItemEvent = new EventEmitter<string>();

  addNewItem(value: string) {
    this.newItemEvent.emit(value);
  }
}
simon caf

saída da diretiva angular

// just use it normal
@Output() itch:EventEmitter<any> = new EventEmitter();

//and call in html
<div appCollar (itch)='scratch()' >
GutoTrosla

@Output () angular

@Input() and @Output() give a child component a way to communicate 
with its parent component.

@Input() lets a parent component update data in the child component. 
@Output() lets the child send data to a parent component.

// Please click source link for more details
Tiny Coders

Respostas semelhantes a “saída angular”

Perguntas semelhantes a “saída angular”

Mais respostas relacionadas para “saída angular” em JavaScript

Procure respostas de código populares por idioma

Procurar outros idiomas de código