Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49184

Custom search function not working on Android 5.1 and lower

$
0
0

@RikEskes wrote:

Hello guys,

I am working on an app which has a built in search function. But when I exectute a search on Android 5.1 or lower in an emulator (and also on my Nexus 7 (2012) tablet running Android 5.1) I get an error saying "undefined is not a function" which is at the first line of the iteration through the list in which it has to search. Whyis this not working properly on all Android versions?

Here is my code:

controllers.js

$scope.vacaturesZoeken = function() {

    // Variable is value of search box
    var zoekterm = document.getElementById('search_id').value;

    // Check whether there is a proper search term in the variable
    if (zoekterm.length === 0 || zoekterm.length === 1) {

        // Variable is null, this will be used to check in the function
        zoekterm = null;

    }

    // Search function
    Vacatures.zoek($scope, zoekterm);
}

services.js

// Defining search function
zoek: function($VacatureZoekLijstscope, zoekterm) {

    // Setting variable for found items to 0
    searched.length = 0;

    // For every item in vacatures
    for (var i = 0; i < vacatures.length; i++) {

        // When the box is checked to only search for location
        if (document.getElementById("locatie_check").checked === true) {

        // Here is where is checked whether the variable is null
        if (zoekterm === null) {

            return false;
        }

        // When the searchterm is in the location property of an item
        else if (vacatures[i].locatie.toLowerCase().includes(zoekterm.toLowerCase())) {

          // Add item to variable
          searched.push(vacatures[i]);

        }
    }

Can anybody tell me what is going wrong with using this on Android devices with version 5.1 or lower? Thanks in advance!

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49184

Trending Articles