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

use*_*611 -3 javascript typescript angular

我编译时遇到此错误

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

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

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)
        });
      } 
Run Code Online (Sandbox Code Playgroud)

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);
      }
Run Code Online (Sandbox Code Playgroud)

Deb*_*ahK 5

我不认为你可以使用参数传递数据类型:

this.tacheService.insert( tache: Tache);
Run Code Online (Sandbox Code Playgroud)

应该

this.tacheService.insert( tache );
Run Code Online (Sandbox Code Playgroud)