0
我一直在寻找一个关于如何在Ionic2/Angular2 Cordova移动应用程序中使用SSL/https的示例,但一直未能找到它。可以在Ionic2/Angular2应用程序中使用HTTPS/SSL吗?
有没有推荐的方法来做到这一点?我一直在寻找{ Http } from '@angular/http'
,但看不到任何明显的暴露。
任何指针将不胜感激。
我一直在寻找一个关于如何在Ionic2/Angular2 Cordova移动应用程序中使用SSL/https的示例,但一直未能找到它。可以在Ionic2/Angular2应用程序中使用HTTPS/SSL吗?
有没有推荐的方法来做到这一点?我一直在寻找{ Http } from '@angular/http'
,但看不到任何明显的暴露。
任何指针将不胜感激。
有了Angular2,当你看到Http对象时,它可能有点误导,它会引导你认为应该有一个Https对象,而不是。要在Http对象中使用https,只需在任何方法[get(URL),post(URL,body)...]的URL字符串参数中指定。例如
export class Example{
private _dataFromGet: {};
constructor(private _http:Http){
this._dataFromGet = {};
}
retrieveData():void{
_http.get("https://SomeUrlHere")
.map(res:Response => res.json())
.subscribe(data => {
this._dataFromGet = data;
});
}
}
啊,这就是它的全部。非常感谢你。 – peterc