【发布时间】:2017-05-21 19:07:42
【问题描述】:
我正在使用 Ionic 2 试图让 Firebase 基于this tutorial 工作,但使用 Ionic rc4。任何帮助表示赞赏。
Your system information: ordova CLI: 6.4.0 Ionic Framework Version: 2.0.0-rc.4 Ionic CLI Version: 2.1.18 Ionic App Lib Version: 2.1.9 Ionic App Scripts Version: 0.0.47 ios-deploy version: Not installed ios-sim version: Not installed OS: Windows 10 Node Version: v6.9.2 Xcode version: Not installed
没有编译错误,但出现以下运行时错误:
Unhandled Promise rejection: Template parse errors: 'h7' is not a known element: 1. If 'h7' is an Angular component, then verify that it is part of this module. 2. If 'h7' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. (" </h2> <p class="chat-text">{{item.chat_text}}</p> [ERROR ->]<h7 class="chat-time">{{item.timestamp | date:'dd/MM/yyyy'}}</h7> </ion-item> </ion-list> "): HomePage@23:6 ; Zone: <root> ; Task: Promise.then ; Value: Error: Template parse errors: 'h7' is not a known element: 1. If 'h7' is an Angular component, then verify that it is part of this module. 2. If 'h7' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. (" </h2> <p class="chat-text">{{item.chat_text}}</p> [ERROR ->]<h7 class="chat-time">{{item.timestamp | date:'dd/MM/yyyy'}}</h7> </ion-item> </ion-list> "): HomePage@23:6 Stack trace: TemplateParser</TemplateParser.prototype.parse@http://localhost:8100/build/main.js:20796:19 RuntimeCompiler</RuntimeCompiler.prototype._compileTemplate@http://localhost:8100/build/main.js:45698:30 RuntimeCompiler</RuntimeCompiler.prototype._compileComponents/<@http://localhost:8100/build/main.js:45618:56
它似乎引用了HomePage,但我不确定它是否有任何错误。
home.ts
import {Component} from '@angular/core';
import {NavController} from 'ionic-angular';
import {LoginPage} from '../login/login';
import {
FirebaseAuth,
AngularFire,
FirebaseListObservable
} from 'angularfire2';
@Component({
templateUrl: 'home.html'
})
export class HomePage {
firelist: FirebaseListObservable<any>;
chat: any;
constructor(public nav: NavController, public af: AngularFire, public auth: FirebaseAuth) {
this.firelist = this.af.database.list('/chat', { //mengambil data
query: {
orderByChild: 'negativtimestamp', //order dari data yang terbaru
}
});
}
chatSend(va, vi) { //mengirim pesan chat
this.af.database.list('/chat').push({ // menambahkan data chat ke firebase
uid: window.localStorage.getItem('uid'),
img: window.localStorage.getItem('photoURL'),
username: window.localStorage.getItem('displayName'),
chat_text: va.chatText,
timestamp: Date.now(),
negativtimestamp: -Date.now() //buat nanti ambil data yang terbaru
})
this.chat = '';
}
logout() { // melakukan logout
window.localStorage.removeItem('email'); // remove email dari localStorage
window.localStorage.removeItem('uid'); // remove uid dari localStorage
window.localStorage.removeItem('displayName'); // remove displayName dari localStorage
this.auth.logout();
this.nav.setRoot(LoginPage);// kembali ke halaman LoginPage
}
}
【问题讨论】:
-
谢谢,这看起来像错误。这是我从教程下载的代码。我看到 html 有一个
标签。我修改一下看看。