import { Injectable } from 'angular2/core';

@Injectable();
export class CsrfService{

	constructor() {}

	getToken() {
		return this.parseCookie()['csrftoken'];
	}

	private parseCookie() {
		return document.cookie
			.split(';')
			.map(t => t.split('='))
			.reduce((v, t) => { v[t[0]] = (t[1] || ''); return v }, {})
	}
}

import { Injectable } from 'angular2/core';

@Injectable();
export class CsrfService{

	constructor() {}

	getToken() {
		let cookies = this.parseCookie();
		let r = cookies['csrftoken'];
		return r;
	}

	private parseCookie() {
		var cookies = {}
		document.cookie
			.split(';')
			.map(t => t.trim())
			.map(t => t.split('='))
			.forEach((t) => cookies[t[0]] = (t[1] || ''));
		return cookies;
	}
}

Fix cookies parser for Google Chrome
Fix cookies parser for Google Chrome
