angular2-http

Angular 2 http.post() is not sending the request

柔情痞子 提交于 2019-11-26 03:23:53
问题 When I make a post request the angular 2 http is not sending this request this.http.post(this.adminUsersControllerRoute, JSON.stringify(user), this.getRequestOptions()) the http post is not sent to the server but if I make the request like this this.http.post(this.adminUsersControllerRoute, JSON.stringify(user), this.getRequestOptions()).subscribe(r=>{}); Is this intended and if it is can someone explain me why ? Or it is a bug ? 回答1: Since the post method of the Http class returns an

Difference between HttpModule and HttpClientModule

血红的双手。 提交于 2019-11-26 03:17:12
问题 Which one to use to build a mock web service to test the Angular 4 app? 回答1: Use the HttpClient class from HttpClientModule if you're using Angular 4.3.x and above: import { HttpClientModule } from '@angular/common/http'; @NgModule({ imports: [ BrowserModule, HttpClientModule ], ... class MyService() { constructor(http: HttpClient) {...} It's an upgraded version of http from @angular/http module with the following improvements: Interceptors allow middleware logic to be inserted into the

Angular: Cannot find a differ supporting object '[object Object]'

不打扰是莪最后的温柔 提交于 2019-11-26 02:25:25
问题 Im following this tutorial. On the way to get list of users from api.github Im getting error: Cannot find a differ supporting object \'[object Object]\' I think its related to <ul> <li *ngFor = \"#user of users\"> {{user | json}} </li> </ul> In my code because before it there was no any error, and im unsure if data come from get request, just clicking didnt give any error, here is my code so far @Component({ selector: \'router\', pipes : [], template: ` <div> <form [ngFormModel] = \

File Upload In Angular?

自古美人都是妖i 提交于 2019-11-26 00:10:55
问题 I know this is very a general question but I am failing to upload a file in Angular 2. I have tried 1) http://valor-software.com/ng2-file-upload/ and 2) http://ng2-uploader.com/home ...but failed. Has anyone uploaded a file in Angular? What method did you use? How to do so? If any sample code or demo link is provided it will be really appreciated. 回答1: Angular 2 provides good support for uploading files. No third party library is required. <input type="file" (change)="fileChange($event)"