I’m new to Typescript.It has been 3 days.I want to access the data from Firebase.And I access and list. I get an error when I want to pass to another page with (Click) =“item ()”.Where am I doing wrong
data-api.service.ts
{Injectable} from '@angular/core';
import {Http,Response} from '@angular/http';
import 'rxjs';
import {Observable} from 'rxjs/Observable';
@Injectable()
export class DataApi {
private url = 'https://ionic2-9dc0a.firebaseio.com/.json'; // https://ionic2-9dc0a.firebaseio.com
currentphone : any = {};
constructor(private http:Http){
}
getAdress(){
return new Promise(resolve =>{
this.http.get(`${this.url}`)
.subscribe(res => resolve(res.json()))
});
}
}
about.ts
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import {DataApi} from '../../app/shared/shared';
import {Http, HttpModule} from '@angular/http';
import {TeamsPage} from '../teams/teams';
@IonicPage()
@Component({
selector: 'page-about',
templateUrl: 'about.html',
})
export class AboutPage {
names: any;
constructor(public navCtrl: NavController, public navParams: NavParams,
public dataApi:DataApi, public http:Http) {
}
item(){
this.navCtrl.push(TeamsPage);
}
ionViewDidLoad(){
this.dataApi.getAdress().then(data => this.names= data[0]);
console.log("willloaded");
}
}
about.html
<ion-header>
<ion-navbar>
<ion-title>Select Tournament </ion-title>
</ion-navbar>
</ion-header>
<ion-content>
<ion-list>
<button ion-item *ngFor="let item of names" (click)="item()">
<h2> {{item.name}}</h2>
</button>
</ion-list>
</ion-content>
data.json
[
[
{
"id": 15,
"name": "Sahne Sistemleri",
"image": "sahne/1.jpg",
{
"image": "sahne/1.jpg"
}
},
{
"id": 16,
"name": "Görüntü Sistemleri",
"image": "sahne1/1.jpg"
},
{
"id": 17,
"name": "Podyum Sistemleri",
"image": "sahne2/1.jpg"
},
{
"id": 18,
"name": "Masa, Sandalye ve Loca Grupları",
"image": "sahne3/1.jpg"
},
{
"id": 19,
"name": "Çadır Sistemleri",
"image": "sahne4/1.jpg"
},
{
"id": 20,
"name": "Mobil Jenaratör Hizmetleri",
"image": "sahne5/1.jpg"
},
{
"id": 21,
"name": "Simultane(Çeviri) Sistemleri",
"image": "sahne6/1.jpg"
}
]
]