1. 原来Http不能直接加在普通类里,下面的报错
import { Component } from '@angular/core';import { NavController } from 'ionic-angular';import { Http } from '@angular/http';@Component({ selector: 'page-about', templateUrl: 'about.html'})export class AboutPage { constructor(public navCtrl: NavController, http: Http) { }}
如果是服务,就ok
import { Injectable } from '@angular/core';import { Http } from '@angular/http';import 'rxjs/add/operator/map';@Injectable()export class HttpClientProvider { constructor(public http: Http) { console.log('Hello HttpClientProvider Provider'); }}
2. Ionic2的语法好变态。
报错: Uncaught (in promise): Error: No provider for Http! Error: No provider for Http! at injectionError
解决的办法居然是:在src/app/app.module.ts里面加上
import { HttpModule } from '@angular/http';
并且在@NgModule里面的imports里面加上HttpModule
2017-09-27
如果发现ionic2页面切换的时候,有残影,就是由A页面切到B页面,B页面已经显示了,A页面才慢慢地,慢慢地消失。
解决办法,A或B页面的HTML代码被包在<ion-content>标签里。