私は別の角度2の成分に角度2サービスをフックしようとしていながら、私はこのエラーを持っている:角度2:エラー:src/app/mage/mage.component.ts(19,98): '、' expected。)app/mage/mage.component.ts(19,100):名前 'response'を見つけることができません。
ERROR in ./src/app/mage/mage.component.ts
Module build failed: Error: /Applications/MAMP/htdocs/angular2/ng2/src/app/mage/mage.component.ts (19,98): ',' expected.)
/Applications/MAMP/htdocs/angular2/ng2/src/app/mage/mage.component.ts (19,100): Cannot find name 'response'.)
なぜこの出来事はありますか?可能であれば、私を助けようとします、そして、downvoteをしないでください。これは、Angular 2での2日目です。私はAngular 2のnoobです。私の最後のAngular 2の質問は、downvotingによって殺されました。否定的なスコアに入った。
import { Component } from '@angular/core';
import { MageService } from './mage.service';
import { OrdersStats } from './orders.stats';
import { OrderStatusStat} from './order.status.stat';
@Component({
selector: 'my-mage',
templateUrl: './mage.component.html',
styleUrls:['./mage.component.css']
})
export class MageComponent {
ordersStatistics:OrdersStats;
constructor(private mageService: MageService) { }
ngOnInit() {
this.mageService.getMagentoData().subscribe(response => <OrdersStats>this.ordersStatistics = response);
}
}
これはorders.stats.ts:
export class OrdersStats {
total:number;
orderStatusesStats:OrderStatusStat[];
}
これは、負の地獄の深:)
これはmage.component.tsあるに私をdownvotingないいただきありがとうございますmage.service.ts:
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import { Response } from '@angular/http';
import { OrderStatusStat } from './order.status.stat';
import { OrdersStats } from './orders.stats';
import 'rxjs/add/operator/map';
@Injectable()
export class MageService {
constructor(private http: Http) { }
getMagentoData() {
return this.http.get("http://localhost:80/angular2/ng2/middleware/MiddleWare.php")
.map(response => <OrdersStats>response.json().data);
}
}
これはorders.status.stat.tsです:
export class OrderStatusStat {
status:string; //Name of the status
count:number; //How many orders with this status
totalAmount:number; //Total amount of all orders with this status
}
あなたは私たちにmage.component.ts' 'からいくつかのコードを表示することができますか? – Riscie
@Riscieコードが追加されました。 –
この行: 'this.mageService.getMagentoData()。subscribe(レスポンス=> this.ordersStatistics =レスポンス);'あなたのように書くことはできません。 '(返り値なし) –
Riscie