我能够按照添加数据的说明,该部分很容易理解。但是当我试图按照指示编辑数据时,我完全迷失了。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 ......并且没有任何工作是按照我喜欢的方式进行的。
帮助将不胜感激。