A rookie gets started and asks for a simple ng2 http request method
I hope you can list the modules and introduced variables for me. Thank you
.A rookie gets started and asks for a simple ng2 http request method
I hope you can list the modules and introduced variables for me. Thank you
.import { Observable } from 'rxjs/Observable';
import { Injectable } from '@angular/core';
import { HttpEvent, HttpInterceptor, HttpHandler, HttpRequest, HttpResponse } from '@angular/common/http';
import 'rxjs/add/observable/throw';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/catch';
import { environment } from '../../environments/environment';
@Injectable()
export class DemoHttpInterceptor implements HttpInterceptor {
constructor() {}
public intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<Result<any>>> {
req = req.clone({
url: `${environment.base}${req.url}`
});
//
const started = Date.now();
//
return next
.handle(req)
.do((event: HttpEvent<any>) => {
if (event instanceof HttpResponse) {
//
const elapsed = Date.now() - started;
console.log(`Request for '${req.urlWithParams}' took ${elapsed} ms.`);
}
})
.catch((res: HttpResponse<any>) => {
switch (res.status) {
case 401:
break;
case 404:
break;
case 500:
case 502:
break;
}
//
return Observable.throw(res);
});
}
}
I use @ Input to define the value @ Input () product:ProductModel; within the subcomponent. then change the product value when the parent component triggers the event and pass it to the child component < details_main [product] = "product " > < de...
find a tool that can debug ng2! it is difficult to debug, especially when debugging UI libraries ...
app.component.ts import { Component } from @angular core ; @Component({ selector: app-root , templateUrl: . app.component.html , styleUrls: [ . app.component.css ] }) export class AppComponent { title = app ; stock = "...
1. At first, I wrote the interface in each component.ts . 2,server.ts ...
angular1.7.11.4.4ng g component xxx ask for help ~ ...
nz-table but it is useless, ask the boss to solve it! http: ng-alain.com https: ng.ant.design -sharp compo. ...
1, display configuration document 2i18n.service.ts } 3 ...
follow the course, still request mock data of less than 8000 port "data of port 8000 can be requested directly to , but request 8000 port at port 4001. , help me with some suggestions ...
Uncaught Error: Template parse errors: md-toolbar is not a known element: 1. If md-toolbar is an Angular component, then verify that it is part of this module. git: https: github.com yyccQQu 0405newNg tree dev my-app ...
npm install @ ngrx core @ ngrx store-- save reports errors in both angular2 and angular4 ...
I want to see how to close the router page or return to the previous router page after the user enters the page. A prompt box appears when the user clicks OK and then closes or returns. Can bosses do this? ...
original text: import { Component, Inject, ReflectiveInjector } from "@angular core"; import { OverlayContainer } from "@angular material"; import { environment } from ".. environments environment"; @Component({ selecto...
http: localhost:4200 login git: https: github.com yyccQQu 04. ...
recently in learning angular, it should be said that angular2, because he learned vue, before coming into contact with angular, always compares the relationship between the two in the learning process, contrasts with each other to learn and use, using tw...
as above, I want to change jobs in the next recruitment season. I want to learn ng, from the needs of companies in the market, but it is very difficult. I don t know which version to read first. In fact, I have read the tutorials of angular5 and have so...
for example, now you need to jump between different projects, the backend is not allowed, and the second project needs to get the information of the first project ...
in Vue-router, you can set keep-alive to keep components from being destroyed, which is good for recording user form submissions and multiple filters. similar requirements are encountered in the angular4 project. Currently, we can only use a large num...