How to show the result (data) of Query FUNCTION in html (How to use Json?)


#1

I want to display the data on the screen in this way:

Calling the function on HomePage (home.ts):
image

calling the data that I need in on database (service.ts):

Well, I think that is must be simple, mas I’m a beginner at ionic2, and I don’t know how to display the result of query on HTML =/
Someone can help me, please?


#2

Hi

you need interpolation, using {{ }}

Check https://angular.io/guide/template-syntax for examples

Basic angular stuff…

Regards

Tom


#3

But its doesn’t work, its a function that I called and not a property of class or event.

if I put interpolation, causes the following error. I don’t know if exist other form to calling a function to bring my data on html

image


#4

totalCartoes returns a Promise that you are ignoring. Instead, assign it to a controller property in a then block, and then you can use the interpolation mentioned above.

this.cartaoService.totalCartoes().then(tc => this.totalCartoes = tc);

#5

I didn’t understood. =/

I wanna tried to convert of result to json

image

But still doesn’t work

And I don’t know why how to convert too


#6

I resolved with json.