我试图显示在header.component.ts中定义的模型,并且我想在另一个组件中显示该模型。我是新来的角度帮助我。
HTML:
<a (click)="openSignup()" class="btn btn-success text-white">signup</a>
这是我的 header.component.ts
import { Component, OnInit, Inject } from '@angular/core';
import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material';
import { Router } from '@angular/router';
import { AuthService } from '../../admin/services/auth.service';
import { CookieService } from 'ngx-cookie-service';
@Component({
selector: 'app-header',
templateUrl: './header.component.html',
styleUrls: ['./header.component.css']
})
export class HeaderComponent implements OnInit {
constructor(public dialog: MatDialog, public aS:AuthService, public router: Router, public cokkie:CookieService) { }
ngOnInit() {
}
openSignup(): void {
let dialogRef = this.dialog.open(SignupDialog, {
width: '500px',
data: { name: "test" }
});
dialogRef.afterClosed().subscribe(result => {
console.log('The dialog was closed');
});
}
}
和 signup-dialog.component.ts
@Component({
selector: 'signup-dialog',
templateUrl: 'signup-dialog.html',
styleUrls: ['./header.component.css']
})
export class SignupDialog {
constructor(
public dialogRef: MatDialogRef<SignupDialog>,
@Inject(MAT_DIALOG_DATA) public data: any) { }
onNoClick(): void {
this.dialogRef.close();
}
}
我想在另一个组件中打开此模型,但出现此错误_co.openSignup is not a function