How to filter or Search element in observableArray list


#1

this is no example on the docs

import { Observable } from “data/observable”;
import { ObservableArray, ChangedData, ChangeType } from “tns-core-modules/data/observable-array”;

export class HomeViewModel extends Observable {
public source = new ObservableArray([
{“name”:“android”},{“name”:“IOS”}]);
public items = new ObservableArray([]);

constructor() {
    super();
    //this.onSubmit();
}
onSubmit(){
    alert("IOS")
    while(this.items.length > 0) {
        this.items.pop();
    }

    this.source.forEach(function (element) {
        if (element.name === "IOS") {
            this.items.push(element);
            alert(this.items);
        }
    });
}