我正在尝试在Angular 4中创建HTTP拦截器,但我有一些奇怪的错误.以下是我的错误:
Argument of type 'Observable<Response>' is not assignable to parameter of type 'Observable<Response>'.
Run Code Online (Sandbox Code Playgroud)
以下是我的代码:
import { Injectable } from '@angular/core';
import { Http, ConnectionBackend, RequestOptions, RequestOptionsArgs } from '@angular/http';
import { Router } from '@angular/router';
import { Observable } from 'rxjs/Observable';
import * as _ from 'lodash';
@Injectable()
export class HttpInterceptor extends Http {
constructor(backend: ConnectionBackend, defaultOptions: RequestOptions, private _router: Router) {
super(backend, defaultOptions);
}
request(url: string | Request, options?: RequestOptionsArgs): Observable<Response> {
return this.intercept(super.request(url, options)); // Here is …Run Code Online (Sandbox Code Playgroud)我正在考虑使用Passport在Laravel 5中开发一个完整的身份系统.
以下是我的要求:
我试过的事情:
我知道OAuth 2.0不是身份验证协议.相反,它使用称为授权的东西,但我们可能会使其工作以支持此处提到的身份验证协议.这是Laravel护照支持的吗?
如何以MM/DD/YYYY格式自定义mat-datepicker日期?
我正在使用以下配置:
HTML:
<mat-form-field>
<input matInput [matDatepicker]="picker" placeholder="Choose a date">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
</mat-form-field>
Run Code Online (Sandbox Code Playgroud)
TS:
import {Component} from '@angular/core';
/** @title Basic datepicker */
@Component({
selector: 'datepicker-overview-example',
templateUrl: 'datepicker-overview-example.html',
styleUrls: ['datepicker-overview-example.css'],
})
export class DatepickerOverviewExample {}
Run Code Online (Sandbox Code Playgroud)
当我打印表单值时,它给出了以下输出:
2017年12月31日星期日00:00:00 GMT + 0530(IST)
我期待MM/DD/YYYY的格式.
我试过这个配置:https://material.angular.io/components/datepicker/overview#customizing-the-parse-and-display-formats
但它对我不起作用.我正在使用默认的MatNativeDateModule(不是时刻js)
我正在使用IE9和PathLocationStrategy与Angular4但它似乎没有工作.它只是附加"#"无限时间.我尝试添加history.js polyfill,但似乎没有任何工作.
任何人都可以帮助我如何使用PathLocationStrategy与Angular 4和IE9?
更新: 我终于想通了,我们不能在IE9上使用PathLocationStrategy.现在我想弄清楚如何在浏览器的其余部分使用PathLocationStrategy,只有当IE9存在时,切换到HashLocationStrategy.我试图在我的模块中包含以下代码行:
RouterModule.forRoot(COMMON_ROUTES, { useHash: !Boolean(history.pushState) }),
Run Code Online (Sandbox Code Playgroud)
我验证了,!Boolean(history.pushState)在IE9中返回true,在其他浏览器中返回false.但它没有用.即使在IE9中,Angular默认为PathLocationStrategy.有人可以帮忙吗?
我在Angular应用程序中有一个动态创建的组件,如下所示:
const factory = this.resolver.resolveComponentFactory<IMessage>(MessageComponent);
this.component = this.container.createComponent(factory);
this.component.instance.body = message;
Run Code Online (Sandbox Code Playgroud)
它相当于添加<message [body]="message"></message>组件的HTML.
让我们假设,我想在我的动态组件代码中实现类似的东西:
<message [body]="message" #form="my-form" (change)="myFunction()"></message>
如何绑定这些附加变量并通过组件的ts文件更改内部事件?