각도 튜토리얼 here을 보면 다른 모든 사람들처럼 관찰 가능을 가져 오지 않으며 authService를 가져 오지 않습니다. 여기왜 각도 튜토리얼을 Observable로 가져올 필요가 없는지
내가 TS 불평하지 얻기 위해 최소한의 무슨 짓을 :
import { AuthService } from './auth.service';
import { Observable } from 'rxjs/Observable';
import { Injectable } from '@angular/core';
import { HttpEvent, HttpInterceptor, HttpHandler, HttpRequest } from '@angular/common/http';
@Injectable()
export class AuthInterceptor implements HttpInterceptor {
constructor(private auth: AuthService) {}
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
// Get the auth header from the service.
const authHeader = this.auth.getAuthorizationHeader();
// Clone the request to add the new header.
const authReq = req.clone({headers: req.headers.set('Authorization', authHeader)});
// Pass on the cloned request instead of the original request.
return next.handle(authReq);
}
}
은 내가 아니에요 뭔가를하고, 아니면 그들은 단지 2 명 선으로 튜토리얼을 짧게 유지하기 위해 가져 오기를 건너 뛸 않았다. 여기
간결함을 위해 비 앵귤러 임포트를 생략 한 것 같습니다. 제가 언급 한 수입에 대한 필요성을 없애 버릴 것이라는 것을 알고있는 마술은 없습니다. – cartant
감사합니다. 그것이 내가 추측하고 있던 것이지만, 내가 할 수있는 마술이 있기를 바랬다. –