sharing data using service angular 6

import { Component, Input } from '@angular/core';
//Child-Component
@Component({
  selector: 'app-child',
  template: `
      Say {{ message }}
  `,
  styleUrls: ['./child.component.css']
})
export class ChildComponent {

  @Input() childMessage: string;

  constructor() { }

}
======================================================================
import { Component } from '@angular/core'; 
//Parent-Component data transfer to Child-Component
@Component({
  selector: 'app-parent',
  template: `
    <app-child [childMessage]="parentMessage"></app-child>
  `,
  styleUrls: ['./parent.component.css']
})
export class ParentComponent{
  parentMessage = "message from parent"
  constructor() { }
}

4
9
Rusticmystic 110 points

                                    import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';

@Injectable()
export class DataService {

  private messageSource = new BehaviorSubject('default message');
  currentMessage = this.messageSource.asObservable();

  constructor() { }

  changeMessage(message: string) {
    this.messageSource.next(message)
  }

}

4 (7 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 use service in angular to share data between components share data between components angular subject sharing data between components in angular angular 9 share data between components angular component sharing data between html what are the types of share data between components in angular use service to share data between components angular best way to share data between components in angular angular share data between components rxjs sharing data between components using service angular sharing data between components angular 6 share data angular services share data angular service sharing data with service angular share data between components angular service sharing of data in angular sharing data between components angular 9 share data between components angular 10 angular share data between component and service component data sharing in angular angular sharing data sharing data between components angular 9 using service sharing data through service angular share data between components angular using service in angular how i can share data services in whole application share datato other component angular 10 How to use angular services to share data between components 5 ways to share data between Angular components share data between component angular sharing data between components angular 8 sharing data with other components angular 7 how to share data among multiple components in angular how to share data from one component to another using service in Angular how to share data between components using service in angular How does one share data between components in Angular? data share between components in angular insert update share data components angular share value between components angular how to share data between normal component and entry componnets angular share data from imported component angular how to share data between angular components after getting from http service how to share data between angular components how to share data between components in angular 9 ways to share data between components angular sharing data between components angular 7 share data between components angular angular.io angular share data between services share data angular components share data between components using service in angular 7 share data in service angular angular sharing data between components using service share data between components angular using subject share data betwuen components angular sharing data between service and components t angular 10 how to share data between different components in angular angular how to share data between components angular shared service data sharing angular share data with service what can be used in angular to share data between components sharing data using services in angular 8 share data between components angular example data sharing throug services angular angular using services to share data how to share method between components angular share data between components angular title angular 2 value share data between components share data between components angular router how to share the data between two components in angular 8 how to share data between components in angular using service code evolution how to share data between components in angular using service sharing data different component angular share data between components using service in angular 6 angular using service to share data sharing data between components angular using service sharing data in components angular8 angular share data with a service data sharing in angular how many way to share the data between two components in angular angular share data between components using service share values between components angular different ways of share data between components in angular share data between two components angular data sharing service angular sharing data between components using services in angular angular data sharing parent to child send data from component to component angular without service service share data variable relationship angular share functions between components angular angular data sharing share data between components in angular access data from another component in angular share data from one component to another angular 10 share a data between component methods to share data between angular components angular 8 component sharing data send data in two component angular 11 sharing data from childe to parent angular how to share data between components in angular 4 using service angular sharing data between components angular services components sending each other data transfer data between two components angular 8 sending data through components pass data between components angular using service child to parent sharing data via output() example share data with service angular data sharing between components in angular 8 pass info to component to another component angular shared data between components angular 6 angular 7 passing data between components sharing data between components in angular example input data share angular angular send data from one component to another how can two components share the data between share data between child and parent component data shring between components using service angular move data between components how many ways we can pass the data to one component to another in angular without parent and child angular data between components share data between components angular 8 passing data between 2 component in angular angular share data across components data sharing between components in angular how to share data between components in angular data share between components in angular shared message to child componets in angular share variable between components angular share data from child to parent in angular How to share the data between the components angular create a service to share data angular share variables between components parent to child component in angular 7 how to share data example pass data between components angular 9 how to tack data from diffrent component angular angular send information to another component sharing data between components exhange variable between componenet in angular pass value between components angular fireship angular compoennt communicatipn emit data from one component to another angular share data to another component before it initializes how to pass data between components in angular how can i share 2 components data into a single component in angular how to send information from component to another in angular 6 angular 8 data transfer between components angular component data transfer how to send data from on component to another in ts angular send data to other component How can you share data between components in Angular send data to another component angular 6 angular 10 events between unrelated components sharing information between components angular how to pass data to another component angular 6 how many ways to pass data between components in angular 2020 angular 6 send data from one component to another emit component in another component &lt;component&gt; sharing data between components angular 8 using service how to share a value from a service in angular between apps angular send data between sharing data between components angular angular 6 passing data between components pass data from one component to another emit from one component to another passing data between components angular service share error message across components angular share error message across components angulas exchange data using service in angular share data through service angular 4 ways to send data angular 6 angular data from component to component angular 6 how to pass data between components share data between components using service in angula angular shared data services parent child anuglar angular components share data pulling data from one component to another angular 8 data sharing angular data passing between components in angular 8 data passing between components in angular mediatery service in angular to share data send data from component to component angular passing data between components with viewchild angular 8 share class between different components angular transfer data between components angular parent component share information to child angular 2 passing data between components angular 9 how to pass data from one component to another in angular how to pass value using shared service angular pass data between component typescript angular message service to another child component angular share object between components different page best way to pass msg between component angular9 angular how to pass data from one component to another share data after creating component angular angular sending data between components pass variable value from two siblings component in angular 8 pass data to service angular 6 one component to other component shared component in angular 6 with model input and events how to create variable to pass data from one component to another in angular angular pass data between components using service share data between two components in angular 8 send updated value from one component to another angular 8 angular 9 passing parameters between components angular passing parameters between components angular 8 keep service data shared how to send data between two components in angular how to send data from one component to another in angular 9 angular how to pass values between components how to pass data from one component to anotherusing subject in angular 8 child to paretn data transfert in angular send data between components angular angular pass values between components passing data between components in angular how to share data without component interaction in angular 8 how to share deta between two components in angular sharing data between components angular 6 using service sharing data with a service angular 8 pass data from one component to another in angular 8 passing data between angular components send and receive data between two components angular service send and receive data between two components angular angular send data to another component how to pass data between two components in angular 9 how to pass data from one component to another angular 6 angular data sharing between components passing data between parent and child components angular angular share object between components send variables from one component to another using service angular get data from another component pass data between components angular 8 shared data from child to parent angular 8 send data from one component to another in angular how to pass data from one component to another in angular 6 using shared service angular bw 2 components model data to another component angular 6 sending data from one child to another angular angular data transfer between components exchange data via service angular data sharing between components in angular 6 parent to child data transfer in angular passing data between unrelated components with click angular 9 viewchild angular 9 sibling component share data from parent to child angular 6 child to component data sharing angular 7 send data from one component to another angular pass data between components angular how to pass value from one component to another in angular 6 varables across componenets in angular sending data between components angular sharing data using service angular 6 angular pass data from one component to another share data from one component to another angular 8 pass data from one component to another angular 8 send info to another component angular pass value from one component to another angular how to get data from one component to another component in angular 6 pass data between components data between components angular pass data to another component angular 6 share a variable between components angular sibling component communication angular 9 pass data from one component to another angular pass data from one component to another angular 6 how to share subject between two components in angular 9 pass a values between components how to acces one component in another component how to transfer data cross component using service i angular 8 angular sibling component communication how to sare data between two components with service angular rxjs share data between components how to to share data between components with service and params angular 9 how to pass data from one component to another in angular 8 sibling component communication angular 8 angular shared service share data between react apps share between classes angular 7 passing data between class angular 8 components angular share data between components angular service for sharing data share data using subject angular 9 angular 9 passing data to unrelated components sharing variable value between two methods angular child to parent data sharing in angular passing data between components angular angular shared service between components angular pass data between components angular 8 unrelated component variable pass data between 2 child components angular 7 pass data between 2 child componens angular7 share data between components 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