Search Posts

Category: angular-filters

Angular filter in dropdown – assign empty value to "All" selection

I am filtering angular list using dropdown with filter attached: <div class=”filter-project-type”> <select name=”project-filter” id=”project-filter” ng-model=”projectFilter” ng-options=”project for project in projectName”> <option value=””>All</option> </select> </div> <div> <ul class=”list” ng-show=”showList”> <task-list-element data=’task’ ng-repeat=’task in tasksList | filter: projectFilter’ ></task-list-element> </ul> </div> And here is the controller code $scope.projectName = []; $scope.showList = false; $rootScope.tasksList = {}; retrieveTasksFactory.getTasksList() .then(function (tasks) { var i; $rootScope.tasksList = tasks; if (tasks.length > 0) $scope.showList = true; // I am filling […]

Multi checkbox filter not working in ng-repeat with AngularJS

I have several age range filters done in my AngularJS app. Of the 4 of them, one doesn’t work properly (results don’t match the filter), and I can’t seem to find why. You can see a working example here. The filters look like this: .filter(‘five’, function () { return function ( items,filter) { if(filter)return items.filter(x=>x.age<=4); else return items; } }) .filter(‘child’, function () { return function ( items,filter) { if(filter)return (items.filter(x=>x.age>=5) && items.filter(x=>x.age<=14)); else return […]

How should I sort a list of prices considering different currencies (EUR and GBP)?

I have a list with races, and the purses are in Euros and in GBP, and I need to order by purse considering the currency. Example: GBP19.000 comes firsts, and EUR19.000 comes second, because GB is more valuable than EUR. That’s my Json vm.races = [ {id:1, country: ‘United Kingdom’, flag: ‘flag-gb’, cities:[{name:’Fontwell’, race_type:’J’, start_time: ’09:55′, purse:’26.000′, currency: ‘GBP’}, {name:’Hereford’, race_type:’J’, start_time: ‘5m’, purse:’35.000′, currency: ‘EUR’}, {name:’Wolverhampton’,race_type:’G’, start_time: ’10:50′, purse:’32.000′, currency: ‘EUR’}]}, {id:2, country: ‘South […]

use filter filter in angular dragdrop

here is a plunkr to illustrate my issue. when applying a filter filter to my angular collection (filling in the search box) then dragging the result to one of the wells. the filter is not applied. I attempted using the filter examples provided in the dragdrop documentation but it does not appear to be working. <div class=”well” ng-repeat = “org in orgs” data-drop=”true” ng-model=”org.list” jqyoui-droppable=”{multiple:true, applyFilter: ‘filterIt’}”> Source: AngularJS

How to filter on multiple fields in AngularJS using $filter(‘filter’)

I am creating a site with a search using the query filter in AngularJS. I have found many tutorials on how to implement this search in one field, but none that explain how to search across multiple fields. But not working i want to search using multiple fields with OR logic. If i give name in search box will filter by post_name, if i give category in search box will filter by post_category like this. […]

convert new line /n to a line break in angular

I have a string which contain new line character /n. Trying to display the string. Instead of taking the /n as new line, it displays ‘/n’ as text. $scope.myOutput = ” Hello /n” {{ myOutput | textFormat }} Required -> Hello (on html page) Tried : app.filter(‘textFormat’, function() { return function(x) { return x.replace(/n/g, ‘<br/>’); } Tried css styles like white-space: pre; Source: AngularJS

Angular filter of array of objects by object

In the below code, console.log($scope.gradeC.title); shows the correct output; however the next console line does not show the expected output. I do not understand this behaviour. Any suggestions/pointers would help me to understand this. <html> <head> <script src=””></script> <script> var myApp=angular.module(“myApp”, []); myApp.controller(‘myCtrl’, function($scope, $filter) { console.log(“Inside controller”); $scope.results = { year:2013, subjects:[ {title:’English’,grade:’A’}, {title:’Maths’,grade:’A’}, {title:’Science’,grade:’B’}, {title:’Geography’,grade:’C’} ] }; console.log($scope.results); $scope.gradeC = $filter(‘filter’)($scope.results.subjects, {grade: ‘B’})[0]; console.log($scope.gradeC.title); console.log(($scope.results.subjects|{grade: ‘B’})[0].title); }); </script> </head> <body ng-app=”myApp” ng-controller=”myCtrl”> <h4>Printing […]

AngularJS change currency display by manipulating the $locale

So I’m struggling with this issue for some time now and yet I couldn’t find an answer. Basically I’ve this: const formattedCurrency = $filter(‘currency’)(input); This returns me something like this $0.00 ($ seem to be the default angular curency CURRENCY_SYM:”$”) What I want to achieve is to make this return not $0.00but a dynamic currency, for example €0.00 or £0.00. So let’s assume that I have a html page with this text: I have $0.00 […]

angular js highlighter filter highlight text and change text also

my highlight filter: app.filter(‘highlightWord’, function () { return function (isSectionData, selectedWord) { if (!isSectionData) return ”; // var items = selectedWord.split(” “); var items = selectedWord.trim().replace(/ OR /g, ‘ ‘).replace(/ AND /g, ‘ ‘).replace(/ – /g, ”).replace(/-/g, ”).replace(/”/g, ”).split(‘ ‘); for (var i = 0, len = items.length; i < len; i++) { var pattern = new RegExp(items[i], “gi”); if (isSectionData && items[i] != “”) { isSectionData = isSectionData.replace(pattern, ‘<span class=”highlighted”>’ + items[i] + ‘</span>’); […]

Next Page »