Angular2'nin Yönlendiricisi'nin OnReuse ve CanReuse bölümlerini anlamaya çalışıyorum ve duvara çarpıyorum. Kodumu, here belgelerinden sonra modelledim, ancak bir nedenden dolayı, rota değiştiğinde arama yöntemlerini alamıyorum. Yanlış yaptığımdan emin değilim.yönlendiriciCanReuse ve yönlendirici Rota değiştiğindeOnReuse çağrılmadı
import {Component, NgZone} from 'angular2/core';
import {CanReuse, OnReuse, ComponentInstruction} from 'angular2/router';
import {NgClass} from 'angular2/common';
@Component({
selector: 'product-table',
templateUrl: __resourcePath + '/html/product-list.html',
directives: [NgClass]
})
export class ProductTable implements CanReuse, OnReuse {
public storeProducts: Store_Product__c[] = [];
public selectedStore: string;
public selectedCategory: string;
public errors: { [id: string]: string } = {};
constructor(private zone: NgZone) {
}
routerCanReuse(next: ComponentInstruction, prev: ComponentInstruction) {
console.log('routerCanReuse fired');
return true;
}
routerOnReuse(next: ComponentInstruction, prev: ComponentInstruction) {
console.log('Reusing!');
console.log(next);
this.selectedStore = next.params['selectedStore'];
this.selectedCategory = next.params['selectedCategory'];
this.storeProducts = next.params['storeProducts'];
}
}
'NgClass' Direktiflere eklenmeye gerek yoktur. "NgClass", varsayılan olarak [COMMON_DIRECTIVES] (https://angular.io/docs/ts/latest/api/common/COMMON_DIRECTIVES-let.html) –
'un bir parçası olarak kullanılabilir. tarayıcı konsolunda herhangi bir hata var mı? –
@ GünterZöchbauer hiçbir hata ne olursa olsun – watzon