Answer the question
In order to leave comments, you need to log in
How to get a variable from a service in a component?
Good day!
Tell me how to get a variable from a service in a component?
There is a service where the variable is hardcoded:
public getCurrentRealm(metaEntityConfigtime: MetaEntityConfigtime){
const _realmUuid = '578ba27c-21f1-4d38-b686-397d1b1b4ef5';
metaEntityConfigtime.realmUuid = _realmUuid;
};
How to reflect this _realmUuid variable in the component?
Import of service in a component has made.
Answer the question
In order to leave comments, you need to log in
If I understand you correctly, then the best option is to do so.
Code in service class:
private _realmUuid = '578ba27c-21f1-4d38-b686-397d1b1b4ef5';
public getCurrentRealm(metaEntityConfigtime: MetaEntityConfigtime){
metaEntityConfigtime.realmUuid = this._realmUuid;
};
//для внешнего использования (в компоненте)
get realmUuid(){
return this._realmUuid;
}
...
constructor(private service: YourService){
console.log(this.service.realmUuid);
}
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question