쉽고 이해할 수있는 데이터 추가 지침을 따를 수있었습니다. 그러나 데이터 편집에 대한 지침을 따르려고하면 완전히 잃어 버렸습니다.BreezeJS 편집 데이터가 작동하지 않습니다.
나는 꽤 잘 작동하는 todo 샘플을 따르고 있지만 동일한 원칙을 사용하여 내 프로젝트에 추가하려고하면 아무 것도 작동하지 않습니다. 내 컨트롤러에서
, 나는 다음과 같습니다
function listenForPropertyChanged() {
// Listen for property change of ANY entity so we can (optionally) save
var token = dataservice.addPropertyChangeHandler(propertyChanged);
// Arrange to remove the handler when the controller is destroyed
// which won't happen in this app but would in a multi-page app
$scope.$on("$destroy", function() {
dataservice.removePropertyChangeHandler(token);
});
function propertyChanged(changeArgs) {
// propertyChanged triggers save attempt UNLESS the property is the 'Id'
// because THEN the change is actually the post-save Id-fixup
// rather than user data entry so there is actually nothing to save.
if (changeArgs.args.propertyName !== 'Id') { save(); }
}
}
문제는 내가보기에 컨트롤을 변경할 때 시간의하여 PropertyChanged 콜백 함수가 절대 호출되지 가져옵니다이다. 내가 라인에 브레이크 포인트를 넣어 경우
function addPropertyChangeHandler(handler) {
// Actually adds any 'entityChanged' event handler
// call handler when an entity property of any entity changes
return manager.entityChanged.subscribe(function (changeArgs) {
var action = changeArgs.entityAction;
if (action === breeze.EntityAction.PropertyChange) {
handler(changeArgs);
}
});
}
가 : 여기
는 서비스의 코드입니다 내 프로젝트에서var action = changeArgs.entityAction;
는, 거기에 도달하지 않는다; todo 샘플에서 그렇습니다! 모든 것을 완전히 건너 뛰고 나중에 뷰를로드합니다. 그래서 내 콜백 함수는 전혀 작동하지 않습니다. 그래서 정말 아무 것도 구독하지 않습니다.
변경 사항을 저장하려고 할 때 manager.hasChanges()는 항상 false이며 데이터베이스에서 아무 것도 발생하지 않습니다.
나는이 일을하기 위해 적어도 3 일 동안 노력해 왔으며, 나는이 모든 문제가 얼마나 복잡한 지 완전히 어긋난다.
참고 : JohnPapa의 HotTowel 템플릿을 사용하고 있습니다. 나는 Todo 편집 기능을 따라 Tee를 만들려고 노력했다.
도움을 받으실 수 있습니다.