I have a custom component and I'd like to pass an object to it, how do I do it? It's easy to pass a string, but I can't send anything that's observable or not.
main-page.js
exports.onInit = function(args) {
var page = args.object;
var pageData = new Observable();
page.bindingContext = pageData;
pageData.set('customObject', {label: 'This is my Label'});
// I've tried Observable as well, same undefined
// pageData.set('customObject', new Observable({label: 'This is my Label'}));
}
main-page.xml
<Page xmlns:customOtherControls="xml-declaration/mymodulewithxml">
<customOtherControls:MyControl myString="Works fine" myObject="{{customObject}}" />
<StackLayout>
<Label text="{{customObject.label}}" />
</StackLayout>
</Page>
mymodulewithxml.xml
<StackLayout loaded="onMymodulewithxmlInit">
<Label text="{{myString}}" />
<Label text="{{myObject.label}}" />
</StackLayout>
mymodulewithxml.js
function onMymodulewithxmlInit(args) {
console.log('myString', page.myObject); // "Works fine"
console.log('myObject', page.myObject); // undefined
}