我正在使用ANGLE创建一个基本的Web应用程序.我想创建3列Scrum板.
在第一篇专栏文章中,我想创建一个按钮,只要您单击它,就会打开一个模式对话框.问题是,一旦将模式对话框实现到按钮中,按钮就变得不可见,甚至页脚也消失了.
以下是所有内容:
body.component.html
:
<div class="board-container">
<div class="column" id="offen">
<app-task-form></app-task-form>
</div>
<div class="column" id="bearbeitung">
<!-- Hier kommen Aufgaben in der Kategorie "In Bearbeitung" -->
</div>
<div class="column" id="abgeschlossen">
<!-- Hier kommen Aufgaben in der Kategorie "Abgeschlossen" -->
</div>
task-form.component.html
:
<input type="text" [(ngModel)]="taskTitle" placeholder="Enter task title" />
<button mat-raised-button (click)="openModal()">Open Modal</button>
task-form.component.ts
:
import { Component } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { ModalComponent } from '../modal/modal.component';
@Component({
selector: 'app-task-form',
templateUrl: './task-form.component.html',
styleUrls: ['./task-form.component.css']
})
export class TaskFormComponent {
taskTitle: string = ''; // Eine Eigenschaft, um den Aufgabentitel zu speichern
constructor(public dialog: MatDialog) {}
openModal() {
this.dialog.open(ModalComponent);
}
}
modal.component.ts
:
import { Component } from '@angular/core';
@Component({
selector: 'app-modal',
templateUrl: './modal.component.html',
styleUrls: ['./modal.component.css']
})
export class ModalComponent {
}
app.module.ts
:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms'; // Importiere FormsModule
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { HeaderComponent } from './header/header.component';
import { BodyComponent } from './body/body.component';
import { FooterComponent } from './footer/footer.component';
import { TaskFormComponent } from './task-form/task-form.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ModalComponent } from './modal/modal.component';
@NgModule({
declarations: [
AppComponent,
HeaderComponent,
BodyComponent,
FooterComponent,
TaskFormComponent,
ModalComponent
],
imports: [
BrowserModule,
AppRoutingModule,
FormsModule, // Füge FormsModule hinzu
BrowserAnimationsModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }