transfer data from one component to another angular
import { Component, Output, EventEmitter } from '@angular/core';
@Component({
selector: 'app-child',
template: `
<button (click)="sendMessage()">Send Message</button>
`,
styleUrls: ['./child.component.css']
})
export class ChildComponent {
message: string = "Hola Mundo!"
@Output() messageEvent = new EventEmitter<string>();
constructor() { }
sendMessage() {
this.messageEvent.emit(this.message)
}
}
import { Component } from '@angular/core';
@Component({
selector: 'app-parent',
template: `
Message: {{message}}
<app-child (messageEvent)="receiveMessage($event)"></app-child>
`,
styleUrls: ['./parent.component.css']
})
export class ParentComponent {
constructor() { }
message:string;
receiveMessage($event) {
this.message = $event
}
}
Also in JavaScript:
- ejs include dynamic partial
- swift convert array to json
- how to push mutual array elements in an array nested loop javascript
- js string template decimals
- dataset js
- bootstrap show modal on page load
- how to use redirect in react
- sum of odd numbers in an array javascript
- javascript get elements that exist in two arrays
- devtools failed to load sourcemap when debugging react native
- how to add multiple comment in react
- enable version 12 node glitch
- remove backslash in json array javascript
- boton de copiar en html y js
- ant design react
- javascript this = that
- get input value on keypress jquery
- Firebase: Firebase App named '[DEFAULT]' already exists
- js random minus
- add to set js
- kendo datasource get
- how to update angular version
- javascript countdown 1 minute
- tobe a number jest