zoukankan      html  css  js  c++  java
  • Angular2~HttpClientModule 配置

    angular的资料很少,并且坑很多,报错也不是很好解决,研究这个花了好几天时间。

    首先,先查看自己的anuglar版本是不是4.3.0以上,HttpClient是anuglar4.3中新加入的特性,在package.json中查看

    复制代码
      "@angular/animations": "^4.3.0",
      "@angular/common": "^4.3.0",
      "@angular/compiler": "^4.3.0",
      "@angular/core": "^4.3.0",
      "@angular/forms": "^4.3.0",
      "@angular/http": "^4.3.0",
      "@angular/platform-browser": "^4.3.0",
      "@angular/platform-browser-dynamic": "^4.3.0",
      "@angular/router": "^4.3.0",
    复制代码

    1.在app.module.ts中导入

    import { HttpClientModule } from '@angular/common/http';

    并在imports加入:

    imports: [
    HttpClientModule
    ]
    2.成员模块中加入
    import { HttpClientModule } from '@angular/common/http';
    constructor(
    private myhttp: HttpClient
    ) { }
    就完了基本的配置。
     
    转自:http://www.cnblogs.com/cxd1008/p/7685789.html
  • 相关阅读:
    文件同步工具
    截图工具
    DBF文件工具
    Oracle旗下的开源虚拟机
    远程协助工具
    切换网络IP工具
    MySQL(C#的链接姿势)
    大写URL转小写
    一个textview实现文字在图片上面的效果
    通过代码设置textview颜色
  • 原文地址:https://www.cnblogs.com/yangfantianxia/p/8053242.html
Copyright © 2011-2022 走看看