角材料对话框即使包含在输入组件中也不起作用?

时间:2019-02-19 11:59:43

标签: angular typescript angular-material

Before including dialog in entry component i am getting this obvious error

After adding dialog in entry component i am getting this error

图片1-在输入组件中包含对话框之前,我遇到了这个明显的错误
图片2-在输入组件中添加对话框后,出现此错误

可能是什么错误?

这是我的对话代码

Component({
  selector: "add-seller-dialog",
  templateUrl: "./seller-dialog/add-seller.html",
  styleUrls: ["./seller.component.sass"]
});
export class AddSellerDialog {

  constructor(
    public dialogRef: MatDialogRef<AddSellerDialog>, //@Inject(MAT_DIALOG_DATA) public data: DialogData
    public sellerService: SellerService
  ) {}

  onNoClick(): void {
    this.dialogRef.close({
      close: true
    });
  }

}

HTML代码-从这里我正在调用函数以打开对话框 enter image description here

TS代码(父类)-在这里,我正在使用openAddSellerDialog()函数调用对话框

enter image description here

应用程序模块代码

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";
import { DashboardComponent } from "./admin/dashboard/dashboard.component";
import { ReactiveFormsModule } from "@angular/forms";
import { FormsModule } from "@angular/forms";
import { HttpClientModule, HTTP_INTERCEPTORS } from "@angular/common/http";

import {
  MatGridListModule,
  MatCardModule,
  MatMenuModule,
  MatIconModule,
  MatButtonModule,
  MatToolbarModule,
  MatSidenavModule,
  MatListModule,
  MatInputModule,
  MatPaginatorModule,
  MatSortModule,
  MatSelectModule,
  MatCheckboxModule,
  MatDialogModule,
  MatDatepickerModule,
  MatNativeDateModule,
  MatBadgeModule,
  MatSnackBarModule,
  MatRadioModule,
  MatTabsModule
} from "@angular/material";
import { LayoutModule } from "@angular/cdk/layout";
import { NavComponent } from "./admin/nav/nav.component";
import {
  ProductsComponent,
  AddProductDialog,
  UpdateProductDialog,
  TransferProductDialog
} from "./admin/products/products.component";
import {
  CampaignComponent,
  AddCampaignDialog,
  DeleteCampaignDialog,
  AddSellerDialog
} from "./admin/campaign/campaign.component";

import { MatTableModule } from "@angular/material/table";
import { MatFormFieldModule } from "@angular/material/form-field";
import { ProductService } from "./services/product.service";
import {
  SelectedCampaignComponent,
  OrderDialog
} from "./admin/campaign/selected-campaign/selected-campaign.component";
import { EventComponent } from "./event/event.component";
import { CategoriesComponent } from "./event/main/categories/categories.component";
import { EventNavComponent } from "./event/main/event-nav/event-nav.component";
import {
  EventProductsComponent,
  CartSnackBarComponent
} from "./event/main/event-products/event-products.component";
import { FilterPipe } from "./pipes/filter";
import { EventCartComponent } from "./event/main/event-cart/event-cart.component";
import { EventCheckoutComponent } from "./event/main/event-checkout/event-checkout.component";
import { AuthComponent } from "./auth/auth.component";
import { OrderService } from "./services/order.service";
import { JwtService } from "./services/jwt.service";
import { AuthService } from "./services/auth.service";
import { CampaignService } from "./services/campaign.service";
import { CartService } from "./services/cart.service";
import { HttpTokenInterceptor } from "./Interceptors/http.token.interceptor";
import { AuthGuard } from "./services/auth.guard";
import { ExcelService } from "./services/excel.service";
import { ServiceWorkerModule } from "@angular/service-worker";
import { environment } from "../environments/environment";
import { SellerComponent } from "./admin/seller/seller.component";
import { SellerService } from "./services/seller.service";

@NgModule({
  declarations: [
    AppComponent,
    DashboardComponent,
    NavComponent,
    ProductsComponent,
    CampaignComponent,
    AddProductDialog,
    UpdateProductDialog,
    TransferProductDialog,
    AddCampaignDialog,
    DeleteCampaignDialog,
    OrderDialog,
    SelectedCampaignComponent,
    EventComponent,
    CategoriesComponent,
    EventNavComponent,
    EventProductsComponent,
    FilterPipe,
    CartSnackBarComponent,
    EventCartComponent,
    EventCheckoutComponent,
    AuthComponent,
    AddSellerDialog,
    SellerComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    BrowserAnimationsModule,
    FormsModule,
    ReactiveFormsModule,
    HttpClientModule,
    MatGridListModule,
    MatCardModule,
    MatMenuModule,
    MatIconModule,
    MatButtonModule,
    LayoutModule,
    MatToolbarModule,
    MatSidenavModule,
    MatListModule,
    MatTableModule,
    MatFormFieldModule,
    MatInputModule,
    MatPaginatorModule,
    MatSortModule,
    MatSelectModule,
    MatCheckboxModule,
    MatDialogModule,
    MatDatepickerModule,
    MatNativeDateModule,
    MatBadgeModule,
    MatSnackBarModule,
    MatTabsModule,
    MatRadioModule,
    ServiceWorkerModule.register("ngsw-worker.js", {
      enabled: environment.production
    })
  ],
  providers: [
    { provide: HTTP_INTERCEPTORS, useClass: HttpTokenInterceptor, multi: true },
    ProductService,
    OrderService,
    JwtService,
    AuthService,
    CampaignService,
    CartService,
    AuthGuard,
    SellerService,
    ExcelService
  ],
  entryComponents: [
    AddProductDialog,
    UpdateProductDialog,
    TransferProductDialog,
    AddCampaignDialog,
    DeleteCampaignDialog,
    OrderDialog,
    CartSnackBarComponent,
    AddSellerDialog
  ],
  bootstrap: [AppComponent]
})
export class AppModule {}

1 个答案:

答案 0 :(得分:0)

这是您的错误:

Component({
  selector: "add-seller-dialog",
  templateUrl: "./seller-dialog/add-seller.html",
  styleUrls: ["./seller.component.sass"]
}); <--

删除组件装饰器末尾的;,该错误将消失。