类型' {}'使用MatDialog时

时间:2017-10-14 12:43:06

标签: angular typescript angular-material mddialog

我从4.0.0更新了角度。到4.4。在运行我的项目时,我遇到了一些错误。

我收到此错误:

  

modif.service.ts(36,33):财产' tache'在类型上不存在   ' {}'

modif.service.ts

import { Injectable } from '@angular/core';
import { Headers, Http } from '@angular/http';

import 'rxjs/add/operator/toPromise';
import { Observable } from 'rxjs/Rx';
import { ModifComponent } from './modif.component';
import { TacheService } from './tache.service';

import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import { MatDialogRef, MatDialog, MatDialogConfig } from '@angular/material';
import { Tache } from './tache';


@Injectable()
export class ModifService {
  private headers = new Headers({ 'Content-Type': 'application/json' });
  private tachesUrl = 'api/taches';  // URL to web api

  taches: Tache[] = [];
  tabTaches() {
    return this.taches;
  }
  selectedOption: string;


  constructor(private http: Http, private tacheService: TacheService,
    public dialog: MatDialog) { }


  openDialog(tache: Tache) {
    let config = new MatDialogConfig();

    let dialogRef = this.dialog.open(ModifComponent, config);
    dialogRef.componentInstance.tache = tache;
    dialogRef.afterClosed().subscribe(result => { // Line 36
      this.selectedOption = result;
      console.log(this.selectedOption);
      tache.name = this.selectedOption;

      this.tacheService.modifyS(tache);

    });
  }
}

我使用此服务通过显示对话框来更改待办事项名称。

更新:我还包括modif组件

modif.component.ts

import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { MatDialogRef } from '@angular/material';
import { Tache } from './tache';
import { TacheService } from './tache.service';
import { MAT_DIALOG_DATA } from '@angular/material';


@Component({

  selector: 'modif',
  templateUrl: './modif.component.html',
  styleUrls: ['./modif.component.css']


})

export class ModifComponent {
  tache: Tache;

  constructor(public dialogRef: MatDialogRef<ModifComponent>) { }



}

在更新之前,一切都工作正常。

0 个答案:

没有答案