I have added the following property to the wakanda 2 / angular 4 todo tutorial code:
todoPicture: type image
When I like to upload an image to an existing todo item I get the following:
todo.todoPicture.upload(file).then( result =>{
console.log('saved !')
})
file is the file from an input
todo is an valid entity.
result:
[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)
When printing todo to the console i can seel all other properties but not todoPicture.
Do i need to initialize the todoPicture property when creating the new Todo item first.
At the moment I just have:
```
let todo = ds['Todo'].create({
label: this.newTodoText,
completed: false,
});
todo.save().then(() => {
//alert('saved');
this.todos.push({
ID: todo['ID'],
label: this.newTodoText,
completed: false,
});
this.newTodoText = "";
this.getTodos()
});
```
PS: instead of downvoting, you rather reply with a solution. That would be much more constructive. Or at least write a comment why you think you need to downvote. That would give me the chance to improve my question.
Looks like you added the todoPicture image attribute to the tutorial from https://wakanda.github.io/doc/#/tutorial?section=main-todoangular.
Here are a couple of suggestions to debug this:
Please the first test with Backend Image Attribute access to see whether the image attribute is available in your datastore. If so, create a few entities using datastore API and see if you can access them on client-side using find() or query().
I think the image upload() requires an existing entity in the database, meaning the code todo.save() needs to be finished before calling upload() of image attribute.
Please test by calling upload() on an saved entity using find() and see if it works on todoPicture attribute.
If you still have trouble with uploading to todoPicture. Please test with a new solution built from scratch and just have code to upload to an image attribute in the Angular app. Here is an example I built to test upload() on image attribute with one data class and a simple page. Let me know if it works for you.
Related
I'm getting
Error: Invalid hook call. Hooks can only be called inside of the body
of a function component.
I followed different suggestions here on other questions and also on other forums. The last I tried is this one, but still I can't figure out what's the problem with my code:
function myFunc() {
const locale = useSelector((state) => state.locale);
return <></>;
}
I am really new to react so don't hesistate to tell me if you need me to post further details
I'm trying to get the value of a field from a single type collection in the home page of a strapi plugin.
const test = strapi.query('global-settings').find({},{'externalUrl':1})
It's returning me an Uncaught TypeError: strapi.query is not a function
Any idea why?
I am not sure about the last part of your request.
But remember that those requests are asynchronous, so try adding await to the call.
This is an example of a query I am using.
const user_settings = await strapi.query('user-settings').find({Send_Monthly_Email: true})
So, that's why I don't understand why you have an empty parameter on that query. >> find({},{'externalUrl':1})
I am assuming you are inside a controller or inside a service.
I have a component where each row is a separate component. I'm emitting an event using Echo + Pusher, and I want to scope the event to only refresh the relevant row.
This isn't described in the docs, but there's an old (and possibly outdated) video by Caleb Porzio (creator of Livewire) in this article (last video, ~8m30s) where this is done by adding the relevant ID into the event name.
In my livewire model, I have:
public function getListeners()
{
return [
"HitReceived:{$this->monitorId}" => 'refresh',
];
}
And in my JS I have:
Livewire.emit('HitReceived:' + data.monitorId);
I can see in the console that data.monitorId is set. When I fire an event with id #1, I get a 500 error:
ERROR: Undefined array key "HitReceived1" {"userId":1,"exception":"[object] (ErrorException(code: 0):
Undefined array key \"HitReceived1\" at /vendor/livewire/livewire/src/ComponentConcerns/ReceivesEvents.php:72)
(This all works if I don't scope my event to a particular model instance, but then everything refreshes.)
I was using $this->monitorId in my array of listeners:
public function getListeners()
{
return [
"HitReceived:{$this->monitorId}" => 'refresh',
];
}
But the variable was declared as protected:
protected $monitorId;
I can't quite see why this would have cause the error I was seeing, but changing it to a public property resolved the issue.
I'm trying to track a custom event based on some data, for this I'm spying on my custom event and expecting the event to get trigger or not. Here am trying to reset my spyevent all I get is undefined error
TypeError: undefined is not an object (evaluating 'spyOnEvent(document, 'product.trackVariantChanged').calls.reset')
it('selects a variant without triggering the product.trackVariantChanged event on document', function() {
spyOnEvent(document, 'variantChanged');
spyOnEvent(document, 'product.trackVariantChanged').calls.reset();
App.ColorSelector.init(); // this function automatically calls custom triggers when it calls
App.ColorSelector.selectVariant($colorSelector, 'wms_III_black'); //this function has a depedency on init()
expect('variantChanged').toHaveBeenTriggeredOn(document);
expect('product.trackVariantChanged').not.toHaveBeenTriggeredOn(document);
App.ColorSelector.selectVariant($colorSelector, 'wms_III_white');
expect('variantChanged').toHaveBeenTriggeredOn(document);
expect('product.trackVariantChanged').not.toHaveBeenTriggeredOn(document);
});
from above case App.ColorSelector.init(); this function automatically calls/ should get call fisr and triggers custom event and App.ColorSelector.selectVariant($colorSelector, 'wms_III_black'); this function has a dependency on init() function
So I want to reset the spy before the selectVariant function get called.
For spyOnEvent instead of calls.reset() use spyOnEvent(document, 'customEvent').reset(); it will work.
I am building a plugin in NativeScript.
When I try to access "presentViewController" method on rootViewController, I get the error "property presentViewContrller does not exist".
const rvc = UIApplication.sharedApplication.keyWindow.rootViewContrller;
rvc.presentViewContrller(myViewController, true, completion() {});
It suggests to use presentViewContrllerAnimatedCompletion which does not accept my view controller.
Could you please assist what part of my code (or maybe setup!) is wrong?
The right method name is presentViewControllerAnimatedCompletion only.
You should combine the parameter names with method name while marshalling Objective C to JS/TS.
presentViewController:animated:completion