i'm catching a data from a component and i'm trying to send it to another component via a service
Component1 (Start) : radio box View
<md-radio-button
*ngIf="item.id===1"
value="{{item.value}}"
class="{{item.class}}"
checked="{{item.checked}}"
(click)="onSelectType1(item)"> //here i'm catching the value
{{item.label}}
</md-radio-button>
ts code
public onSelectType1(selected:any){
this.formeService.type1Change(selected.nb)
}
SERVICE :
@Injectable()
export class FormeService{
public type1S : any;
public type1Change(selected):any
{
this.type1S=selected; //here i'm catching it into the service
}
Component 2 : (End) : Simple View
ts code
export class ContentComponent{
constructor(public BackService : BackgroundService ,
public formeService: FormeService)
{
console.log(this.formeService.type1S)
////// that diplays me in the console that it's undefined !!!!!!!!!!!!!!!!!
The probleme is HERE : how may i access to the value of my variable in this part
}
!!!!!!!! and in the same time in the view it displays me the value:
{{formeService.type1S}} // this works normally
who may tell me how can i display the value of my data in the "end component ts code" ?????