请帮助修复角度2材质对话框组件。
我尝试以最简单的形式启动对话框组件。 Here's我得到了什么。问题是,在单击按钮后,对话框将打开,相对于屏幕边缘有一个较大的偏移量。此外,控制台显示以下错误消息:
错误:找不到ConvDialogComponent的组件工厂。你添加了吗? 它到@ NgModule.entryComponents? at noComponentFactoryError(core.es5.js:3202)
app.module.ts:
import { Component } from '@angular/core';
import { MdDialog } from '@angular/material';
import { ConvDialogComponent } from './conv-dialog/conv-dialog.component';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
selectedOption: string;
constructor(public dialog: MdDialog) {};
private openMoneyConverter(): void {
console.log(111);
this.dialog.open(ConvDialogComponent);
};
}
app.component.ts:
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-conv-dialog',
templateUrl: './conv-dialog.component.html',
styleUrls: ['./conv-dialog.component.css']
})
export class ConvDialogComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
CONV-dialog.component.ts:
CheckCreds(value: any) {
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
let params = new URLSearchParams();
params.set('name', (value.nom).toString());
params.set('subname', (value.prenom).toString());
return this.http.get(this.checkUri, {
search: params, withCredentials: true
})
.map(res => {
console.log("++++" + res.text());
return JSON.parse(res.text());
})
.catch(this.handleError)
}
答案 0 :(得分:1)
将ConvDialogComponent
添加到@NgModule.entryComponents
@NgModule({
declarations: [
AppComponent,
ConvDialogComponent
],
imports: [
MdDialogModule,
BrowserAnimationsModule,
MdButtonModule,
BrowserModule
],
providers: [],
bootstrap: [AppComponent],
entryComponents: [ConvDialogComponent]
})