を更新し、ここで問題に直面します。私のプロジェクトにjsファイルをロードするAPIがあります。問題は、私はこのjsファイルを使用する必要があり、それを変更するための私のコントロールではありません、基本的に、このjsファイルはAJAX経由でAPIを呼び出し、配列を返すいくつかのメソッドがあります。 私が必要とするのは、データが入ってくるとすぐにビューを更新することです。多くの方法で試してみましたが、それでもうまくいきません。任意のアイデアをどのようにバインドしてビューを更新できますか?角度2のビューを更新します。角度2の新しい角度
import {Component, AfterContentInit} from "@angular/core";
import {IProduct} from "./product";
import {ProductService} from "./product.service";
declare var ExpressLibraryLoader: any;
@Component({
selector: 'pm-products',
moduleId: module.id,
templateUrl: 'product-list.component.html',
styleUrls: ['product-list.component.css']
})
export class ProductListComponent implements AfterContentInit{
pageTitle: string = 'Product List';
listFilter: string = '';
products = [];
errorMessage: string;
constructor(private _productService: ProductService) {
}
ngAfterContentInit(): void{
//this._productService.getProducts().
// subscribe(products => this.products = products, error => this.errorMessage = <any>error);
ExpressLibraryLoader.initialise({
platformKey: 'xxx',
brandID: 20,
libraryUrl: "http://localhost/xxxxcx/",
domainLaunchUrl: "http://localhost/xcxcxc/",
success: function (ExpressLibrary) {
let parameters =
{
languageCode: 'en',
gameProviderID: [7],
success: function (response) {
if (response.Status === "Success") {
//response.Result.Games.map(response => this.products = response);
this.products = response.Result.Games;
console.log(this.products)
} else {
}
},
error: function() {
}
};
ExpressLibrary.games.getDesktop(parameters);
}
});
}
}
おそらくngZoneを探しています。ここで試してみてください:http://stackoverflow.com/questions/34592857/view-is-not-updated-on-change-in-angular2?rq=1 –