updatePassenger(passenger: Passenger): Observable<Passenger> {
let headers = new Headers({
'Content-Type': 'application/json'
});
let options = new RequestOptions({
headers: headers
});
return this.http
.put(`${PASSENGER_API}/${passenger.id}`, passenger, options)
.map((response: Response) => response.json());
}

From Angular V4, there is new HttpClient module, in which HttpHeaders is an immutable api.

const headers = new HttpHeaders()
.set("X-CustomHeader", "custom header value"); this.courses$ = this.http
.get(
"/courses.json",
{headers})
.do(console.log)
.map(data => _.values(data));

[Angular] Http Custom Headers and RequestOptions的更多相关文章

  1. [Angular] Read Custom HTTP Headers Sent by the Server in Angular

    By default the response body doesn’t contain all the data that might be needed in your app. Your ser ...

  2. [Angular] Create custom validators for formControl and formGroup

    Creating custom validators is easy, just create a class inject AbstractControl. Here is the form we ...

  3. [Angular 2] Custom Validtors

    Create a custom validtor which only accepts the string start with '123'; function skuValidator(contr ...

  4. [Angular 8] Custom Route Preloading with ngx-quicklink and Angular

    In a previous lesson we learned about implementing a custom preloading strategy. That gives you a lo ...

  5. angular 4 http 之web api 服务

    Angular Http是获取和保存数据的.主要是为了取到我json文件里的数据. 直接上代码吧: 1.  先介绍Promise模式的:(直接代码) heroes.json: 1 2 3 4 5 6 ...

  6. 来自 Thoughtram 的 Angular 2 系列资料

    Angular 2 已经正式 Release 了,Thoughtram 已经发布了一系列的文档,对 Angular 2 的各个方面进行深入的阐释和说明. 我计划逐渐将这个系列翻译出来,以便对大家学习 ...

  7. Java EE 7 / JAX-RS 2.0: Simple REST API Authentication & Authorization with Custom HTTP Header--reference

    REST has made a lot of conveniences when it comes to implementing web services with the already avai ...

  8. 记Angular与Django REST框架的一次合作(2):前端组件化——Angular

    注:这是这个系列的第二部分,主要集中在Angular的使用方面.之前使用过AngularJS(Angular 1.x),混在Django的模板中使用,这些页面一般完全是结果展示页.在有Django表单 ...

  9. 从Java角度理解Angular之入门篇:npm, yarn, Angular CLI

    本系列从Java程序员的角度,带大家理解前端Angular框架. 本文重点介绍Angular的开发.编译工具:npm, yarn, Angular CLI,它们就像Java在中的Maven,同时顺便介 ...

随机推荐

  1. 【RHEL7/CentOS7基本配置】

    目录 @ 相比于6.x的版本,Rhel7/CentOS7增加或改进了以下7大特性. 1.身份管理 kerberos的跨平台信任机制:kerberos将完全兼容微软活动目录,实现完全使用活动目录进行认证 ...

  2. JS关键字 import

    今天开发时使用import作为方法名,报错 后查明报错原因:import是js中的关键字,在取方法名时不能取import

  3. 【Uva 10285】Longest Run on a Snowboard

    [Link]: [Description] 在一个r*c的格子上; 求最长的下降路径; [Solution] 记忆化搜索; f[x][y]表示从(x,y)这个格子往下还能走多远; 因为是严格递增,所以 ...

  4. JS 中 this 与闭包的结合产生的问题

    代码片段一: var name = "The Window"; var object = { name : "My Object", getNameFunc : ...

  5. 8.AXIS1基础

    转自:https://blog.csdn.net/chjttony/article/details/6209998 1.AXIS简介: Axis是Apache组织推出的SOAP引擎,Axis项目是Ap ...

  6. POJ 2323 贪心

    题意: 思路: 贪 贪 贪 如果当前的c>之前的c+s 那么之前的合适 一直贪下去就好了 //By SiriusRen #include <cstdio> #include < ...

  7. xsy3320 string

    xsy3320 string 题意: ​ 给一颗树,每条边上有一个字符,求有多少条路径是回文的.(\(N\leq50000\),\(c\in\{1,2\}\)) 题解: ​ 前置芝士:回文前缀& ...

  8. Vue 实现分页+输入框关键字筛选

    分页的实现(Vue+Element)+输入框关键字筛选 1.这里用的是Element 自带的分页组件 <template> <div class="sales-table& ...

  9. TOJ 2233 WTommy's Trouble

    2233.   WTommy's Trouble Time Limit: 2.0 Seconds   Memory Limit: 65536KTotal Runs: 1499   Accepted R ...

  10. 项目报错:Cannot find class file for javax/servlet/ServletException

    两种解决方法: 1. 假设是Maven项目,加入servlet-api依赖包: <dependency> <groupId>javax.servlet</groupId& ...