我正在尝试登录系统。在 Angular 1 中,有一些方法可以设置
withCredentials:true
但我在 angular2 中找不到可行的解决方案
export class LoginComponent {
constructor(public _router: Router, public http: Http, ) {
}
onSubmit(event,username,password) {
this.creds = {'Email': 'harikrishna@gmail.com','Password': '01010','RememberMe': true}
this.headers = new Headers();
this.headers.append('Content-Type', 'application/json');
this.http.post('http://xyz/api/Users/Login', {}, this.creds)
.subscribe(res => {
console.log(res.json().results);
});
}
}
最佳答案
在 Angular > 2.0.0 中(实际上是从 RC2 开始)
http.get('http://my.domain.com/request', { withCredentials: true })
关于javascript - angular2 xhrfields withcredentials true,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35007572/