离子按钮单击可在浏览器和模拟器中工作,而不是在实际设备上工作

时间:2019-03-03 18:27:58

标签: html angular typescript ionic-framework google-cloud-firestore

我正在开发一个应用程序,并且(click)事件似乎在实际设备上不起作用。

tab1的HTML。

<ion-button (click)="favorites(article)" tappable *ngIf="!checkFavorite(article.url)" shape="round"><ion-icon name='heart'></ion-icon></ion-button> 

在tab1.page.ts

import { FirebaseService } from '../firebase.service';

@Component({
  selector: 'app-tab1',
  templateUrl: 'tab1.page.html',
  styleUrls: ['tab1.page.scss']
})
export class Tab1Page {
  constructor(public data: FirebaseService){       
  }

favorites(article) {
    this.data.addToFav(article) ;
  }

在firebase.service.ts

addToFav(object) {
    this.db.collection("favorites").add({
      "title":object["title"],
      "url":object["url"],
      "user":this.afAuth.auth.currentUser.uid,
      "author":object["author"],
      "image":object["urlToImage"],
      "time":object["publishedAt"],
      "source":object["source"]["name"],
      "description":object["description"]
    }).then(data => {
      console.log("Favorite added.");
    }).catch(err => {
      console.log("Error adding favorite.");
    })   
}

我尝试在html中的click事件周围移动,并添加了tappable。但是在真实设备上没有运气。在模拟器和浏览器中都可以正常运行-单击时没有错误。

这两个函数似乎都被正确调用,但是没有项目写入数据库吗?

0 个答案:

没有答案
相关问题