-5

I'm new in Angular I want to pass data from one to another component. I store that in array that is isn't bind with component.html i wonder that i use @Input property if is isn't bind or some other manner?

Walter White
  • 976
  • 4
  • 12
  • 29

1 Answers1

1

You can do this by adding a inject a service for both component then put the data in the service so both can find it. Also you can use the @input and the @output directive , but i prefer the service ( In this service both share the varible is ready ) :

import {EventEmitter, Injectable} from '@angular/core';

      @Injectable()
      export class LoadPageService {
          private isReady= false;
          // Event emitter that make event each time the variabe isReady 
           changes
         Updated: EventEmitter <boolean>= new EventEmitter();
        setdata( value) {
          this.isReady = value;
            this.Updated.emit(this.isReady);
        }

          getdata() {
          return this.isReady;
        }

      }
ZAhmed
  • 1,232
  • 8
  • 15