–Fuse 0.37.0 -build 12471 - Mac OSX
In my app I have a Match
element inside an Each
element but don’t work!!! I think this error also happend in --Fuse 0.36!
My code is something like this:
<App>
<JavaScript>
var Observable = require('FuseJS/Observable');
var EachItems = Observable();
function Item(MyNumber) {
this.MyNumber = MyNumber;
}
EachItems.add(new Item(1));
EachItems.add(new Item(2));
EachItems.add(new Item(3));
module.exports = {
EachItems: EachItems,
};
</JavaScript>
<StackPanel Alignment="VerticalCenter">
<Text TextAlignment="Center" Value="Match / Case ERROR:" Color="#000" />
<Each Items="{EachItems}">
<Match Value="{MyNumber}">
<Case Number="1">
<Text TextAlignment="Center" Value="1" Color="#000" />
</Case>
<Case Number="2">
<Text TextAlignment="Center" Value="2" Color="#000" />
</Case>
<Case Number="3">
<Text TextAlignment="Center" Value="3" Color="#000" />
</Case>
</Match>
</Each>
</StackPanel>
</App>
Please help!
I change the Number
to String
and work!
Like this:
<App>
<JavaScript>
var Observable = require('FuseJS/Observable');
var EachItems = Observable();
function Item(MyNumber) {
this.MyNumber = MyNumber;
}
EachItems.add(new Item("1"));
EachItems.add(new Item("2"));
EachItems.add(new Item("3"));
module.exports = {
EachItems: EachItems,
};
</JavaScript>
<StackPanel Alignment="VerticalCenter">
<Text TextAlignment="Center" Value="Match / Case ERROR:" Color="#000" />
<Each Items="{EachItems}">
<Match Value="{MyNumber}">
<Case String="1">
<Text TextAlignment="Center" Value="1" Color="#000" />
</Case>
<Case String="2">
<Text TextAlignment="Center" Value="2" Color="#000" />
</Case>
<Case String="3">
<Text TextAlignment="Center" Value="3" Color="#000" />
</Case>
</Match>
</Each>
</StackPanel>
</App>
Uldis
May 4, 2017, 8:38am
3
Hi Cristian,
I am fairly certain that this is a case of variable type mismatch. If you check the docs, you will see that Match
takes more options than just Value="..."
, where each of them implies a specific data type for the data-bound variable: https://www.fusetools.com/docs/fuse/reactive/match#section-table-of-contents
Now, back to your example, in case of numbers you would want to do something like this:
<Match Number="{MyNumber}">
<Case Number="1">
...
Hope this helps!
Great! Thank you very much!!!