0
DB에 "플레이어"를 나타내는 모델 개체가 있습니다. 그것의 구현 거기에 내 애플 리케이션에서 다른 VM의에서 바인딩하고 싶습니다 선수의 배열입니다. 예를 들어 변화는 (응용 프로그램의 다른 부분) 플레이어 배열했을 때에Aurelia의 속성 및 컬렉션 옵저버가 속성을 올리지 않음 변경된 이벤트
import {Players} from './models/players';
import {inject, BindingEngine} from 'aurelia-framework';
@inject(Players,BindingEngine)
export class App {
constructor(playersProvider,bindingEngine) {
this._playersProvider = playersProvider;
this._bindingEngine = bindingEngine;
this._subscription = this._bindingEngine.propertyObserver(this,this._playersCount)
.subscribe(this.objectValueChanged);
}
async activate() {
await this._playersProvider.initialize();
this._playersCount = this._playersProvider.players.length;
}
objectValueChanged(newVal,oldVal) {
console.log("new : " + newVal + ", old val : " + oldVal);
}
deactivate() {
this._subscription.dispose();
}
}
는 불행히도 변화 _playersCount 속성에 반영되지 않는다. 예 : -이 속성에 바인딩 된 UI 레이블은 새로 고쳐지지 않으며 objectValueChanged는 결코 호출되지 않습니다.
U 동일한 라이브러리에서 collectionObserver를 사용하여 다른 VM에서 동일한 문제가 발생합니다.
어떤 도움이 필요합니까?
구문은 다음과 같습니다. this._bindingEngine.propertyObserver (this, '_playersCount')' –