0
I’m having the following problem while trying to return a string
of a variable of service
for any other function, which is strange because all variables are strings like the return of functions.
test.service.ts
private oneString:string = "hi";
getOneString(): string {
return this.oneString.
}
myFunction.ts
constructor(private testeService: TesteService) { }
private myString:string = this.service.getOneString;
console.log(myString);
Error: Type '() => string' is not Assignable to type 'string'
Did you notice that in your constructor you declared
testeService
and in myString calledservice
?– Albertt Santos
Oops, typo, but thank you.
– Sabrina
Leave the question uncorrected so the next person who searches for this error can also be helped.
– Albertt Santos
beauty, already returned to the service.
– Sabrina