角度2错误TS1005:','预计

时间:2017-05-04 22:05:05

标签: javascript angular typescript

编译时出现此错误

我找不到我应该添加逗号的位置。

src/app/navbar.component.ts(29,39): error TS1005: ',' expected.
src/app/tache.service.ts(53,53): error TS1005: ',' expected.

navbar.component.ts

      add(name: string): void {
        name = name.trim();
        if (!name) { return; }
        this.tacheService.create(name)
        .then(tache => {
             this.tacheService.insert( tache: Tache); // the first error ( line 29)
        });
      } 

service.ts

update(tache: Tache): Promise<Tache> {
        tache.stat = 1;
        return this.http
          .put(this.tachesUrl, JSON.stringify(tache.stat:1), {headers: this.headers}) // second error ( line 53 )
          .toPromise()
          .then(() => tache)
          .catch(this.handleError);
      }

2 个答案:

答案 0 :(得分:5)

我认为您不能使用参数传递数据类型:

this.tacheService.insert( tache: Tache);

应该是

this.tacheService.insert( tache );

答案 1 :(得分:0)

this.tacheService.insert( tache: Tache); // the first error ( line 29)
this.tacheService.insert( tache); // No Error
return this.http
    .put(this.tachesUrl, JSON.stringify(tache.stat:1), {
        headers: this.headers
    }) // second error ( line 53 )
    .toPromise()
    .then(() => tache)
    .catch(this.handleError);
return this.http
    .put(this.tachesUrl, JSON.stringify(tache.stat), {
        headers: this.headers
    }) // No Error
    .toPromise()
    .then(() => tache)
    .catch(this.handleError);