我在Wakanda2/ angular 4TODO教程代码中添加了以下属性:todoPicture: type image

当我想要将图片上传到现有的待办事项时,我会得到以下信息:
todo.todoPicture.upload(file).then( result =>{ console.log('saved !') })
file是来自输入todo的文件是一个有效的实体。
结果:[Error] ERROR – TypeError: undefined is not an object (evaluating 'todo.todoPicture.upload') TypeError: undefined is not an object (evaluating 'todo.todoPicture.upload') error View_TodoComponent_1 (TodoComponent.ngfactory.js:13) logError (vendor.bundle.js:14702) (anonymous function) handleError (vendor.bundle.js:2375) (anonymous function) (vendor.bundle.js:10527) (anonymous function) (vendor.bundle.js:20184) onInvokeTask (vendor.bundle.js:5176) runTask (polyfills.bundle.js:2809) invokeTask (polyfills.bundle.js:3116) invokeTask (polyfills.bundle.js:4157) globalZoneAwareCallback (polyfills.bundle.js:4183) [Error] ERROR CONTEXT – DebugContext_ {view: Object, nodeIndex: 9, nodeDef: Object, …} DebugContext_ {view: Object, nodeIndex: 9, nodeDef: Object, elDef: Object, elView: Object, …}DebugContext_ error View_TodoComponent_1 (TodoComponent.ngfactory.js:13) logError (vendor.bundle.js:14702) (anonymous function) handleError (vendor.bundle.js:2380) (anonymous function) (vendor.bundle.js:10527) (anonymous function) (vendor.bundle.js:20184) onInvokeTask (vendor.bundle.js:5176) runTask (polyfills.bundle.js:2809) invokeTask (polyfills.bundle.js:3116) invokeTask (polyfills.bundle.js:4157) globalZoneAwareCallback (polyfills.bundle.js:4183)
当打印todo到控制台时,我可以删除所有其他属性,但不能删除todoPicture。
首先创建新的Todo项时,是否需要初始化todoPicture属性。
目前我只有:`label let todo = ds'Todo'.create({ :this.newTodoText,completed: false,
});
todo.save().then(() => {
//alert('saved');
this.todos.push({
ID: todo['ID'],
label: this.newTodoText,
completed: false,
});
this.newTodoText = "";
this.getTodos()
});附言:你宁愿用一个解决方案来回答,而不是否决。这将是更有建设性的。或者至少写一条评论,说明为什么你认为你需要投反对票。这将给我一个机会来改进我的问题。
发布于 2018-04-17 02:57:48
看起来您从https://wakanda.github.io/doc/#/tutorial?section=main-todoangular向教程添加了todoPicture图像属性。
这里有几个建议来调试它:
请使用find()对已保存的实体调用upload()进行测试,并查看它是否适用于todoPicture属性。
如果您仍然无法上载到todoPicture,请使用
https://stackoverflow.com/questions/49718326
复制相似问题