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?
Asked
Active
Viewed 102 times
-5
-
2you need to look at this document https://angular.io/guide/component-interaction – Raed Khalaf Aug 09 '17 at 07:03
-
1do bit research – k11k2 Aug 09 '17 at 07:03
1 Answers
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