我的网站中的Mat Dialog突然停止工作,没有任何错误,所以我没有注意到它何时停止工作,我从来没有在完成后编辑该页面,所以我很困惑为什么它突然不工作。它可能是由角更新引起的?Heroku更新?软件?或者如果没有,这是我的代码吗?但我敢肯定它以前工作,因为我有一个旧的副本,我的代码日期为2021(不是我的github中更新的代码),将其与可能的最新代码进行比较,但它是相同的,所以我想听听其他意见,如果在Angular 或heroku的更新可以导致这一点。
这里是我的主页的.ts文件:
import { Component, OnInit } from '@angular/core';
import { ShipAssetsDialogComponent } from './ship-assets-dialog/ship-assets-dialog.component';
import { Router } from '@angular/router';
import { MatDialog } from '@angular/material/dialog';
@Component({
selector: 'app-ship-assets',
templateUrl: './ship-assets.component.html',
styleUrls: ['./ship-assets.component.css']
})
export class ShipAssetsComponent implements OnInit {
ship1 = [
{name: 'Capt. ', label1: 'Master'},
];
constructor(public dialog: MatDialog, private router:Router) { }
ngOnInit(): void {
}
scrollUp(event){
setTimeout(() => {
this.scroll(event.path[3].attributes[1].nodeValue);
}, 200);
}
scroll(id) {
let el = document.getElementById(id);
el.scrollIntoView(true);
}
openDialog(imgSrc){
this.dialog.open(ShipAssetsDialogComponent, {
height: 'auto',
width: 'auto',
data: {
imgSrc: imgSrc
}
});
}
}
下面是我的Mat对话框的.ts文件的代码
import { ShipAssetsComponent } from './../ship-assets.component';
import { Component, Inject, OnInit } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
@Component({
selector: 'app-ship-assets-dialog',
templateUrl: './ship-assets-dialog.component.html',
styleUrls: ['./ship-assets-dialog.component.css']
})
export class ShipAssetsDialogComponent implements OnInit {
imgSrc:string;
{image: 'https://ship.jpg', name: 'CAPTAIN SQUID', title1: 'CAPTAIN',
publication:[
]},
];
myArr = [];
publi:boolean = false;
constructor(public dialogRef: MatDialogRef<ShipAssetsComponent>,
@Inject(MAT_DIALOG_DATA) public data: any) { }
ngOnInit(): void {
this.myArr = this.professors.filter(res => res.name === this.data.imgSrc);
console.log(this.data.imgSrc);
}
}
这是我的应用程序.module.ts
import { SafePipe } from './shared/SafePipe';
import { AuthGuard } from './shared/auth.guard';
import { MaterialModule } from './material/material.module';
import {IvyCarouselModule} from 'angular-responsive-carousel';
import { FormsModule,ReactiveFormsModule } from '@angular/forms';
import { AngularFireStorageModule } from '@angular/fire/storage';
import { AngularFireModule } from '@angular/fire';
import { HttpClientModule } from '@angular/common/http';
import { CarouselModule } from 'ngx-owl-carousel-o';
import { NgImageSliderModule } from 'ng-image-slider';
import {MatDialogModule} from '@angular/material/dialog';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
@NgModule({
declarations: [
AppComponent,
SafePipe,
],
imports: [
BrowserModule,
AppRoutingModule,
MatDialogModule,
BrowserAnimationsModule,
MaterialModule,
IvyCarouselModule,
CarouselModule,
FormsModule,
ReactiveFormsModule,
HttpClientModule,
AngularFireStorageModule,
AngularFireModule,
NgImageSliderModule,
AngularFireModule.initializeApp({
apiKey: "abc",
authDomain: "abc.com",
databaseURL: "https:abc.com",
projectId: "abc",
storageBucket: "abc.com",
messagingSenderId: "123",
appId: "1:123:web:123abc"
}),
],
providers: [AuthGuard],
bootstrap: [AppComponent]
})
export class AppModule { }
注意:我也试过添加订阅,但仍然不起作用
1条答案
按热度按时间tvokkenx1#
我找到了解决办法。我在什么地方读到入口组件不再需要了,但是我试着把它添加到我的app.module.ts上,结果成功了!
我有3页我使用这个垫子对话框的地方,所有的都突然停止工作。当我尝试添加这个它工作了(我上次(2021年)从来没有添加过这个,但仍然工作)