美文网首页
Ionic3 封装服务

Ionic3 封装服务

作者: 没有昵_称 | 来源:发表于2017-11-24 14:03 被阅读514次
    1. 新建一个类,命名为app.service.ts,位于src/app/目录下,具体代码如下:
import { LoadingController, AlertController, ToastController } from 'ionic-angular';
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/toPromise';

@Injectable()
export class AppGlobal {
  
}

@Injectable()
export class AppService {

    constructor(public http: Http, ) { }

   
 
}


2.在app.module.ts文件中添加入下代码:


image.png

3.使用封装的服务,比如在mian.ts中使用,具体代码入下:


image.png

相关文章

网友评论

      本文标题:Ionic3 封装服务

      本文链接:https://www.haomeiwen.com/subject/luixbxtx.html