Javascript
var pageData = new Observable({
appointmentsList: appointmentsList,
user_role: ''
});
exports.onLoaded = function (args) {
page = args.object;
page.bindingContext = pageData;
pageData.set('user_role', appSettings.getString('role'));
XML
<Repeater items="{{appointmentsList.booking_dates.bookings}}">
<Repeater.itemsLayout>
<StackLayout class="appointment-rows" />
</Repeater.itemsLayout>
<Repeater.itemTemplate>
<StackLayout>
<WrapLayout visibility="{{ user_role === 'agency' ? 'visible' : 'collapse' }}">
<Label text="{{user_name}}" class="row-client-name row-client-name-new" />
</WrapLayout>
</StackLayout>
</Repeater.itemTemplate>
</Repeater>
In above snippet that problem is i am not able to access user_role
inside Repeater
.
Can anybody help me how to access outer element inside Repeater
?
Thanks.
Based on this https://docs.nativescript.org/core-concepts/data-binding#example-4-creating-listview-child-items-based-on-the-itemtemplate, You can try something like this:
<WrapLayout visibility="{{$parents['Repeater'].user_role,$parents['Repeater'].user_role === 'agency' ? 'visibile' : 'collapse' }}">
or this way
<WrapLayout visibility="{{$parents['Page'].user_role,$parents['Page'].user_role === 'agency' ? 'visibile' : 'collapse' }}">