Angular JS

Always use Restangular instead of $resource or $http

Advantages of Restangular over $http It uses promises. Instead of doing the “magic” filling of objects like $resource, it uses promises. You can use this in $routeProvider.resolve. As Restangular returns promises, you can return any of the methods in the $routeProvider.resolve and you’ll get the real object injected into your controller if you want. It… Continue reading Always use Restangular instead of $resource or $http

Angular JS

Using $cookieStore in Angular JS

app.controller(‘MainCtrl’, [‘$cookieStore’, function($cookieStore) { $cookieStore.put(‘icar’,car); // to store values on cookies var car_detail = $cookieStore.get(‘icar’); // to retrieve values on cookies $cookieStore.remove(‘icar’); // to remove cookies }

Angular JS

Angular JS Dynamic searching for a collection of objects, with min & max range (i.e., persons with age from 18 to 60)

View:- <div ng-repeat=”car in cars | filter: byRange(fieldname, min_value, max_value” > ……. …… </div> Controller:- $scope.byRange = function (fieldName, minValue, maxValue) { if (minValue === undefined) minValue = Number.MIN_VALUE; if (maxValue === undefined) maxValue = Number.MAX_VALUE; return function predicateFunc(item) { return minValue <= item[fieldName] && item[fieldName] <= maxValue; }; }; That’s it just pass in… Continue reading Angular JS Dynamic searching for a collection of objects, with min & max range (i.e., persons with age from 18 to 60)