mirror of
				https://github.com/NativeScript/NativeScript.git
				synced 2025-11-04 04:18:52 +08:00 
			
		
		
		
	chore: updated ui sample to work with latest ObservableArray changes (#10065)
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							7860d515a8
						
					
				
				
					commit
					e2c2f1f4a6
				
			@ -70,9 +70,11 @@ export class MainPageViewModel extends TestPageMainViewModel {
 | 
			
		||||
 | 
			
		||||
	private filterListView(value: string) {
 | 
			
		||||
		if (!MainPageViewModel.checkIfStringIsNullEmptyOrUndefined(value)) {
 | 
			
		||||
			let array = MainPageViewModel.ALL_EXAMPLES.filter((testExample, index, array) => {
 | 
			
		||||
				return MainPageViewModel.stringContains(testExample.path.toLowerCase(), value.toLowerCase()) || MainPageViewModel.stringContains(testExample.name.toLowerCase(), value.toLowerCase());
 | 
			
		||||
			});
 | 
			
		||||
			let array = Array.from(
 | 
			
		||||
				MainPageViewModel.ALL_EXAMPLES.filter((testExample, index, array) => {
 | 
			
		||||
					return MainPageViewModel.stringContains(testExample.path.toLowerCase(), value.toLowerCase()) || MainPageViewModel.stringContains(testExample.name.toLowerCase(), value.toLowerCase());
 | 
			
		||||
				})
 | 
			
		||||
			);
 | 
			
		||||
			this.filteredListOfExamples = new ObservableArray(array);
 | 
			
		||||
		} else {
 | 
			
		||||
			this.filteredListOfExamples = null;
 | 
			
		||||
 | 
			
		||||
@ -20,7 +20,8 @@ export class Issue5039ViewModel extends Observable {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	filter(value: string = '') {
 | 
			
		||||
		const filteredItems = this._items.filter((item) => -1 !== item.indexOf(value));
 | 
			
		||||
		this.items.splice(0, this.items.length); // remove all items
 | 
			
		||||
		this.items.push(this._items.filter((i) => -1 !== i.indexOf(value)));
 | 
			
		||||
		this.items.push(...filteredItems);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user