import { ViewModel } from "./filtering-model" ; import { Page } from "tns-core-modules/ui/page" ; import { RadListView } from "nativescript-ui-listview" ; let page ; let bindingContext ; export function onPageLoaded ( args ) { page = args . object ; bindingContext = new ViewModel ( ) ; page . bindingContext = bindingContext ; } export function toggleFilter ( ) { const listView = page . getViewById ( "myListView" ) as RadListView ; if ( ! listView . filteringFunction ) { listView . filteringFunction = bindingContext . myFilteringFunc ; bindingContext . isEnabled = true ; } else { listView . filteringFunction = undefined ; bindingContext . isEnabled = false ; } }