api.service.ts
//imports...
@Injectable({
providedIn: 'root',
})
export class ApiService{ public images = environment.imgUrl ;}
constructor(public http: HttpClient) {}
...
second.service.ts
imports...
export class second.service.ts implements OnInit {
public _api: apiService;
ngOnInit(): void {
this._api = this.injector.get(ApiService);
}
getImgUrl(){
return this._api?.images; // images property cannot be accesssed but it is defined and can be accessed in api.service.ts
}
}
I tried adding public _api = ApiService in constructor of second.service.ts
But it results in page/ did not render in 30 seconds error.
user14150778 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1