Open yaasoof opened 6 years ago
in home.ts
import { Component,OnInit } from '@angular/core'; import {NavController, Platform} from 'ionic-angular'; import Parse from 'parse'; @Component({ selector: 'page-home', templateUrl: 'home.html' }) export class HomePage { Persons=[]; GameScore = Parse.Object.extend("GameScore"); constructor(public navCtrl: NavController,public platform: Platform,) { Parse.initialize("Xeei69RmgHC6jzwvs7fAfhlFm65FlhsLW8gmmZu3", "mJ0lNgLqWbL3VrI4ME798KhwlaWoCiJCCfpQ8DhF"); Parse.serverURL = 'https://parseapi.back4app.com/'; let query = new Parse.Query("GameScore"); query.find() .then(function (results) { for(let items of results ){ this.Persons=items; } console.log(this.Persons); }).catch(function(error) { console.log(error) }); } }
in home.html
<ion-header> <ion-navbar> <ion-title>Home</ion-title> </ion-navbar> </ion-header> <ion-content padding> <h1>{{title}}</h1> <h2>My favorite hero is: {{myHero}}</h2> <button >Heroes:</button> <ul> <li *ngFor="let Person of Persons "> {{ Person.Age }} </li> </ul> </ion-content>
and in console `
I believe you have to push instead of assign because Persons is an array.
Persons
for(let items of results ){ this.Persons.push(items); }
But, you could just do:
this.Persons = results;
in home.ts
in home.html
and in console `