在我们的Angular 4.3项目中,我们分别有公共站点组件和安全站点(登录)组件。我们使用@angular/common/http. 我们想为public-site组件和secured-site组件实现不同的http拦截器。例如,
LoggingInterceptorLoggingInterceptorAuthTokenInterceptor(在请求标头中传递身份验证令牌)我们尝试使用不同的拦截器HTTP_INTERCEPTORS在每个组件级别添加提供者详细信息@Component。但是请求不会进入任何拦截器。
仅当我们HTTP_INTERCEPTORS在@NgModule. 这里的问题是,公共站点 http 请求也会进入AuthTokenInterceptor不需要的。
那么我们应该如何解决这个问题呢?谢谢。
我正在使用 bootstrap-select 1.12.4 版本和 Angular 4.3.5。
我正在尝试使用 http 调用和异步管道加载下拉选项。
我面临的问题是,刷新页面时,大多数情况下都不会加载选择下拉选项。但有时选项会加载。我不确定我在这里犯了什么错误。有人能帮我一下吗?提前致谢。
组件.ts
import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
@Component({
selector: 'app-bob-report',
templateUrl: './bob-report.component.html',
styleUrls: ['./bob-report.component.css']
})
export class BobReportComponent implements OnInit {
observableOptions: Observable<any>;
constructor(private http: HttpClient) { }
ngOnInit() {
this.observableOptions = this.http.get('assets/data/users.json');
}
}
Run Code Online (Sandbox Code Playgroud)
组件.html
<form>
<div class="form-group">
<label for="sel1">Select list (select one):</label>
<select class="selectpicker" data-live-search="true">
<option *ngFor="let option of observableOptions | async" value={{option.id}}> {{option.value}} </option> …Run Code Online (Sandbox Code Playgroud)