Download this package
open terminal cd into this directory and run node app.js
| //Now we can inject underscoreJS in the controllers | |
| function MainCtrl($scope, _) { | |
| //using underscoreJS method | |
| _.max([1,2,3,4]); //It will return 4, which is the maximum value in the array | |
| } |
| var underscore = angular.module('underscore', []); | |
| underscore.factory('_', function() { | |
| return window._; // assumes underscore has already been loaded on the page | |
| }); |
| var data = ['a','b','c','a','s','b']; //This array contains duplicates | |
| _.uniq(data); | |
| //Ouput | |
| ['a','b','c','s','b'] //duplicates removed | |
| //Also works on array of objects | |
| var objs = [{name:"Samsung"}, {name: "LG"}, {name:"Sony"}, {name:"Samsung"}]; //contains duplicate objects | |
| _.uniq(objs); | |
| //output |
| var data = [{model:"T", manufacturer: "ford"}, | |
| {model:"S", manufacturer:"tesla"}, | |
| {model:"r8", manufacturer:"audi"}, | |
| {model:"fiesta", manufacturer:"ford"}]; | |
| //Code to fetch all the ford cars | |
| var fordCars = _.where(data, {manufacturer: "ford"}); | |
| //output | |
| [{model:"fiesta", manufacturer:"ford"},{model:"T", manufacturer: "ford"}] |
| package com.mohammedlakkadshaw.ken; | |
| import java.util.Vector; | |
| import org.xml.sax.XMLReader; | |
| import android.text.Editable; | |
| import android.text.Html; | |
| import android.text.Spannable; | |
| import android.text.style.BulletSpan; |