【发布时间】:2020-08-25 03:40:24
【问题描述】:
我正在尝试在 Angular 中创建一个对话框,但该对话框未显示在中心,仅显示为左侧的垂直白色矩形。 我将附上一张描述确切问题的图片:screenshot of the page。
- 我的
appmodule.ts文件中包含了入口组件 - 编译时没有错误。
标题component.ts文件:
import { Component, OnInit } from '@angular/core';
import { MatDialog, MatDialogRef } from '@angular/material';
import { LoginComponent } from '../login/login.component';
@Component({
selector: 'app-header',
templateUrl: './header.component.html',
styleUrls: ['./header.component.scss']
})
export class HeaderComponent implements OnInit {
constructor(public dialog: MatDialog ) { }
ngOnInit() {
}
openLoginForm() {
this.dialog.open(LoginComponent, {width: '500px', height: '450px'});
}
}
【问题讨论】:
-
您是否在项目中添加了@angular/material 样式?
-
你能详细点吗,我没听懂
-
我在 @Santosh 的回答中的 cmets 中看到您已经添加了样式。如果这是您要添加材料的项目,我建议您使用
ng add @angular/material。它会执行@angular/material 入门指南中描述的所有步骤,将其添加到您的项目中。如果这是一个 Ivy 项目,则在NgModule定义中不需要任何entryComponents。
标签: javascript node.js angularjs reactjs