Thursday 27 February 2014

Knockoutjs Array First

Array First returns only first matched value. If exist more than one item then ignore it.

 var arrayFirst = function (labelName, arrayCollection) {
         try {
                 if (arrayCollection.length > 0) {
                     return ko.utils.arrayFirst(arrayCollection, function (item) {
                         return (item.labelName.toLowerCase().indexOf(labelName.toLowerCase()) > -1);
                     });
                 };
          }
          catch (ex) {
               //TODO: as per need.
          }

  }; 

No comments:

Post a Comment