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)
  }
}

3.33
6
Pjs36 95 points

                                    import { Component } from '@angular/core';

@Component({
  selector: 'app-parent',
  template: `
    Message: {{message}}
    &lt;app-child (messageEvent)=&quot;receiveMessage($event)&quot;&gt;&lt;/app-child&gt;
  `,
  styleUrls: ['./parent.component.css']
})
export class ParentComponent {

  constructor() { }

  message:string;

  receiveMessage($event) {
    this.message = $event
  }
}

3.33 (6 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
how to send and receive data from one component to another in angular to same variable how to send and receive data from one component to another in angular how to send data from one component to another in angular using ancher tag access data from one component to another angular how to transfer data from one componenet to another in angular how to transfer data from one component to another in angular through route transfering data from one component to other in angular how to send data from one component to another in angular 9 send data from one component to another in angular 8 taking data from one component to another angular how to use data from one component to another in angular 8 how to send data from one component to another component in angular8 how to transfer data from one component to another component in angular best way to transfer data between components angular sending data from one component to another in angular sending data from one component to another component angular 9 angular transfer data between components pass data from one component to another angular 9 transfer data from one component to another angular 6 how to send data from one component to another component in angular how to transfer data between components in angular how to send data from 1 component to another in angular how to send data to a component from another component in angular send data from one component to another in angular 9 how to transfer data from one component to other component in angular 10 angular data transfer between components how to get data from one component to another in angular 8 pass data from one component to another angular 8 use data from one component to another angular 8 how to send data from one component to another in angular 8 data transfer from one component to another in angular 8 angular how to transfer data between components how to transfer data from one component to another component in angular 6 passing data from one component to another angular 8 how to transfer data from one component to another in angular using service how to send data from one component to another component in angular 8 how to transfer data from one component to another component in angular 8 47. How transfer data one component to another component? in angular . How to transfer data one component to another component in angular angular send data from one component to another emit data from one component to another in angular pass data from one component to another using event in angular 8 passdata from one component to other of ts file of angular angular 8: send value one component to another component through service how to pass the data from one component to another component in angular anglar one component get another component data why need send data to another component why we are need send data to another component in angular why we are need send data one to another component in angular send data from one component to another angular data binding from one component to another angular angular passing data from one component to another angular send data to another component how to get data from one component to another in angular angular share variable between parent and child angular cli how to pass data from one form to another angular sharing data between components sharing data between angular components passing data from one component to another angular how to send the value to one to anohter component in angular material angular send data from component to component share data between components angular data transfer one sim to another component in angular next method data transfer one sim to another component in angular store data not transfer other component how to get value from one component to another in angular 7 angular send data from component to service sharing data between components angular 8 parent child interaction angular 8 Angular transfer a component from a model to another pass values from one component to another in angular share object from parent ts to child component get data from one component to another angular how to fetch form data from one component to another using @viewChild how to fetch form data from one component to another using viewChild how to pass data to antother component angular angular read val from other component how to pass data from one component to another in angular 10 how to pass data from one component to another in angular 8 emit data from one component to html how to transfer data from one component to another in angular data transfer from one component to another in angular 6 3 ways for components to share data angular passing value from one component to another angular pass input from one component to another angular how to transfer value from one component to another in angular 7 service how to transfer value from one component to another in angular 7 pass variable data from one component to another angular pass value from one component to another angular how to pass data one component to another component in angular 8 angular pass data from one component to another transfer data between various components angular pass data one component to another angular 8 how to send information from component to another in angular 6 how to send data from one component to another in ts angular access another component variable angular change variable in another component data between two components send data to another component in angular send value from one component to another angular 8 send data to another component angular how to pass the data from one component to another component in angular 10 diffrent ways to transfer data from one compo how to get value from another component angular send data from one component to another how to send data to another component in angular how to display all data from one component to another in angular pass value from one component to another angular 6 pass data from one component to another transfer data from one component to another angular how to pass data from one component to another angular passing values component to other ts file how to send data in unrderr component in angular transfer saved data from one component to another angular how to send data from one component to another in angular transfer data from one component to another angular 8 how to pass information from one component to another in angular angular pass value from one component to another pass data from one component to another angular how to use one component in another component in angular 8 pass some component to another component in angular 6 angular pass information between components send data from one component to another in angular
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source