FAQ Database Discussion Community


Angular JS category filter not working recursively

javascript,jquery,angularjs,angularjs-directive,angularjs-filter
I'm developing a file filter based on angular js. Now I'm facing an issue while filtering results based on categories and the respective sub categories. If I select a category id=a then the files assigned to category a and its descendant subcategories also should be shown. Any one please help...

AngularJS - Filter list by object property that has filter applied to it

javascript,angularjs,angularjs-ng-repeat,angularjs-filter
I want to filter a list of objects by their properties and used the filter filter. The problem is that some object properties have filters applied to them that change the format in which they are displayed (see formatDate filter in code below) and the filter filter will use the...

AngularJS ng-repeat query filter not show for nested object

javascript,angularjs,angularjs-ng-repeat,angularjs-filter
I have the following data, how to query string under "talent"? I used ng-Repeat='friend in friends', but it can't search the data under talent. For example: When I type piano, I expect it show the John node. <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Example - example-example98-production</title> <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script> </head>...

AngularJS: How to write ascending sort filter

angularjs,angularjs-filter
I'm learning AngularJS and as an exercise trying to write an ascending sort filter: This is my html file: <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script src="../Scripts/angular.min.js"></script> <script src="../Scripts/Controllers/app.js"></script> </head> <body ng-app="myApp"> <ul ng-init="names = ['Peter','Anton','John']"> <li ng-repeat="name in names | sortAscending "> <span>{{name}}</span> </li> </ul>...

Getting a matching element from a different array

angularjs,angularjs-filter
I have an array called groupUsers and another array within an array called tasks.users which look like this: this.groupUsers = [ {$id: "simpleLogin:1", name: "bob"}, {$id: "simpleLogin:2", name: "joe"}]; this.tasks = [ {title: "do something", users:["simpleLogin:1","simpleLogin:2"]}, {title: "do something else", users:["simpleLogin:2"]}]; What I am trying to do is to get...

Angularjs groupBy + orderBy

javascript,angularjs,angularjs-filter
I am using groupBy from angular-filter to group an array of objects by their date property. <div ng-repeat="(day, dayEvents) in events | groupBy: 'date' )"> <h3>{{ day | date: mediumDate }}</h3> </div> Which produces the following: Feb 9, 2015 Feb 10, 2015 Feb 11, 2015 Feb 12, 2015 How can...

using ng-repeat angular with filter to exclude blank value

angularjs,angularjs-ng-repeat,angularjs-filter
I'm trying to get non-blank elements in my select using filter, but this doesn't work properly. <select ng-model="selectedSubject.id"> <option value="0"> <%= res.getString("portlet.form.subjectField.default") %> </option> <option ng-repeat="sujet in subjects.allSubjects | filter:{name_fr:'!!'}" value="{{sujet.id}}"> {{sujet.name_fr}} </option> </select> ...

Angular JS, remember checkbox status when filtering

angularjs,checkbox,ng-repeat,angularjs-filter
I'm trying to create a list with checkboxes with a search box. HTML <div ng-controller="MainCtrl"> <input type="text" placeholder="Search" ng-model="query"> <div ng-repeat="item in items | filter:query"> <input type="checkbox" id="{{item.id}}" value="{{item.id}}">{{item.name}} </div> </div> JS myApp.controller('MainCtrl', function ($scope) { $scope.items = [ { "id": 1, "name": "Green", }, { "id": 2, "name": "Yellow",...

How to filter with multiple values in ui-grid? (angularjs)

javascript,angularjs,angularjs-filter,angular-ui-grid
I'm trying to make a filter with passing multiple values for the filter but have only a single return. field: 'name', filter: { condition: function(searchTerm, cellValue) { var strippedValue = (searchTerm).split(';'); //console.log(strippedValue); for (i = 0; i < strippedValue.length; i++){ if (cellValue.indexOf(strippedValue[i]) == -1) return false; return true; } //return...

AngularJS: Display the first element of the response array

arrays,angularjs,angularjs-scope,angularjs-ng-repeat,angularjs-filter
I currently have a form with two dynamic dropdowns (Location & Branch). When one of Location values is selected, Branch will automatically populate the corresponding branches with that location. <select ng-model="formData.location" ng-options="rg as rg.type for rg in region"> <option value="">Choose Location</option> </select> <select ng-model="formData.branches" ng-options="c as c[formData.location.displayName] for c in...

Can we access user input value in customfilter.Trying to access user input number from controller or directly in customfilter

javascript,angularjs,angularjs-scope,angularjs-controller,angularjs-filter
I am new to angular js .Here I am trying to filter data based on the temperature by subtracting the user input(x) from the currentTemp variable.But not sure if i could access the user input value in custom filter.I am planning use same thing on date later on.For now this...

Include calculated value in angular filter results

javascript,angularjs,angularjs-filter
Is it possible to apply a filter to a value calculated from a dataset without modifying the actual dataset? For example - <input ng-model="query"> <li ng-repeat='val in values | filter:query'> {{val.a}} + {{val.b}} </li> I would want to search on the result of val.a + val.b...

Custom search filter in angularjs

javascript,angularjs,angularjs-filter
I am using the inbuilt search filter of angular js like this- <!--header starts--> <input class="form-control fs-mini search" ng-model="search.name" type="text" placeholder="&#xe80a Search"> <!--header ends--> <!--content area--> <div ng-repeat="user in users | filter:search"> {{ user.name }} {{user.l}} {{user.time}} </div> <!--content area ends--> Now i removed the header template codes and created...

how to shorten content text of html string while binding to view with ngBindHtml

javascript,angularjs,angularjs-filter
I'm binding an html string to view using ngBindHtml. the string contents are plain text along with anchor elements. for a plain text with ngBind I can use a filter like this one to limit text length to a certain word count. I've tried it by creating a temp element...

“htmlToPlaintext” AngularJS (1.3.15) Custom Filter

angularjs,angularjs-filter
I am trying to create a custom filter , but despite following the correct structure I think something is wrong. angular.module('App', []) .filter("htmlToPlaintext", function() { return function(text) { return String(text).replace(/<[^>]+>/gm, ''); } }) .controller ('mainCtrl',['$scope','$filter', function($scope,$filter){ $scope.items=[ {id: '1', title: '<b>Chicago</b>'}, {id: '2', title: '<b><i>New York</i></b>'}, {id: '3', title: '<div><p>Washington</p></div>'}...

Adding a filter in angularjs

angularjs,angularjs-filter
I am new with angularjs and I am trying to create a filter that remove spaces from a string. removeSpaces.js angular.module('filters.stringUtils', []) .filter('removeSpaces', [function() { return function(string) { if (!angular.isString(string)) { return string; } return string.replace(/[\s]/g, ''); }; }]) home.html <div ng-controller="ItemController"> <p ng-repeat="item in items"> <a href="/items/{{ item.item_name |...

Custom Filter in AngularJS Custom directive

javascript,angularjs,angularjs-directive,angularjs-scope,angularjs-filter
I 've seen some other questions with similar problem as mine but I can't grasp the way that this is done. In this plunk : Plunk example. var app = angular.module('myApp', ['directives', 'services']); angular.module('services', []).filter('selectedItems', function() { return function(fields, parent) { var arrayFields = []; for (var i = parent;...

How to filter objects in array by category key in Angular ng-repeat

javascript,angularjs,angularjs-directive,angularjs-ng-repeat,angularjs-filter
I'm trying to use Angular filter to display only sorted tags by category Example of a tag object in tags array: { term: term, id: id, category: category } The ng-repeat tags: <li ng-repeat="(k, m) in tags | filter: filterTags | orderBy:predicate:reverse" ng-class="{'selected': m.selected}" ng-click="selectTag(m)"> <div class="tag">{{m.term}}</div> </li> The sort...

How to get an AngularJS controller in a filter

angularjs,angularjs-directive,angularjs-filter
Is it possible to use dependency injection to reference a controller inside of a filter? I tried the following: app.filter('myFilter', function(MyCtrl) {...}) app.controller('MyCtrl', function(...) {}) But I get an error that MyCtrl dependency cannot be found....

Compare and filter data with date in MM/DD/YYYY format from current date using using new Date() while subtracting new Date() from user input value

javascript,angularjs,datetime-format,angularjs-filter,datetime-comparison
Trying to compare the new Date(today's date) in 2015-02-21T21:48:48.137Z format with date in MM/DD/YYYY format which is my json data. I would like to filter all the data before today's days based on user input based on number of day's user enters(getting data before no certain number of days)..I can...

Two identical nested ng-repeat filters from JSON - One doesn't work?

javascript,json,angularjs,angularjs-ng-repeat,angularjs-filter
I have a few JSON data sources that I use to filter through data in ng-repeat loops. One set works perfect together, the other (which is seemingly identical) does not and I have no idea why. Module: var app = angular.module('myApp', ['app.services.data']); Services angular.module('app.services.data', []) .service('emails', ['$http', function($http){ var promise...

How to sort array in ng-options by key?

javascript,angularjs,select,angularjs-filter,angularjs-ng-options
There is such array: month: Array[13]0: "M"1: "January"2: "February"3: "March"4: "April"5: "May"6: "June"7: "July"8: "August"9: "September"10: "October"11: "November"12: "December" I do: ng-options="key as value for (key, value) in data.month | orderBy:key" But I get unsorted select list. ...

dd-collapse-text with emoji filter

javascript,angularjs,angularjs-directive,mean-stack,angularjs-filter
I'm using dd-collapse-text directive to collapse descriptions in my webpage and works fine. <span data-dd-collapse-text="350" data-ng-bind-html="description"></span> Result example (not for 350 characters): Lorem Ipsum ... (more) But, now I want to use it for the comments; and they are filtered with emoji filter for the icons. And this is not...

Filters not working on array from resource

arrays,angularjs,angularjs-filter,angularjs-resource
I have a filter that is not returning anything when it is run on an array from a factory. But when I copy paste the array directly into the filter, it works fine. There must be a simple solution, and it is driving me crazy. This works: $filter('filter')([ {"name":"firstItem","code":"one"}, {"name":"secondItem","code":"two"},...

issue with angularjs ui tree filtering at child level

angularjs,angular-ui,angularjs-filter,angular-ui-tree,angularjs-ui-utils
Angularjs UI tree filtering feature is not working at child level however it is working fine at group level. For example if we type node1 or node2 filtering works fine, but if we type node1.2 or node2.1, filtering won't work properly. Please find plnkr If I add the following code...

How to filter outer array records on the basis of inner array value

angularjs,angularjs-ng-repeat,angularjs-filter
I have an object of array inside another object. So, there are two nested ng-repeat in my html. I am trying to hide the label data if ACTION is not "Changed" for ex. in below example, last row "Changed L3" should not display. My scope data: $scope.groups = [{ "label":...

Editable AngularJS Input Filter

javascript,html,angularjs,filter,angularjs-filter
I've got an array of objects loaded into an ng-repeated list. That list is filtered based on the value entered in an input field just above it when a user clicks the 'filter' button. That works fine. However, I also want a select dropdown next to the input to edit...

Change src img directive or filter angular

javascript,angularjs,angularjs-directive,angularjs-filter
I'm trying to implement a resize for images, so I don't request a big image file. Therefore, I need to change the 'src' of the img tag to redirect it to a resize service. I have been trying to make a directive which specify the size that I want to...

Covert encoded HTML in string to plain text for Input Fields using Agular

javascript,html,angularjs,angularjs-directive,angularjs-filter
I have a use case, where we can have '&#' characters inside of a JSON. Name: "Kenneth Hinsvark &#38; Maurice McAlister" Address: "555555 W. Canyon Dr &#35; B212" The string values are pulled back from a database. Apparently the values were saved to the DB with HTML encoding. I need...

AngularJS Filter by Inline Expression

javascript,angularjs,expression,angularjs-filter
I'm trying to add an inline Angular filter that filters via an expression that evaluates to true or false. Here's my JS: angular.module('programApp', [ 'programApp.controllers', ]); angular.module('programApp.controllers', []) .controller('programController', ['$scope', '$filter', function($scope, $filter){ $scope.advancedFilters = 1; $scope.bars = [ {'name':'First', 'id':1}, {'name':'Second', 'id':2}, {'name':'Third', 'id':3}, {'name':'Fourth', 'id':4}, {'name':'Fifth', 'id':5}]; }]);...

Filter ng-repeat by a property in the current scope

javascript,html,angularjs,angularjs-filter
I have tried the following (in a template loaded by a directive): <li ng-repeat="lang in languages | filter: { Culture: '!{{currentLanguage}}'}"> this is not working, all languages are rendered <li ng-repeat="lang in languages | filter: { Culture: !currentLanguage}"> this is not working, no languages are rendered languages has a property...

Angularjs display timestamp date in different timezones

angularjs,angularjs-filter
I can properly display a selected timestamp to the local time for that timestamp by just using date:'medium'. What I want to achieve though is displaying this timestamp in a certain timezone, for example UTC+03:00 or GMT+03:00 just to give an example. I have tried to use date:'medium':'UTC+03:00' date:'medium':'UTC+0300' date:'medium':'GMT+03:00'...

Dynamically add filter in ng-repeat

angularjs,angularjs-ng-repeat,angularjs-filter
I am building a table where the rows and columns are built entirely based on the data that is sent to it. I'm very close to having it work, I'm having trouble figuring out how to build a custom filter and pass in the filter patterns dynamically The object that...

AngularJS: Filter with ng-options

angularjs,angularjs-filter
I am able to use filters on my options when filtering the entire object, but I only want the filter apply to the name property, which I can't get working. The below results in no changes to what is displayed in the select regardless of anything being typed in the...

Number filter filters number down to two decimals, but does not display it that way

angularjs,angularjs-filter
This is what I see: The value is set at 160.90, but displays as 160.8999999999 etc. <input class="form-control" ng-model="imprint.total" value="{{imprint.total | number:2}}" readonly> It goes through filtering of certain inputs to get that total, but essentially it's just a price multiplied to quantity....

Angular custom filter doesnt work on server

javascript,angularjs,angularjs-ng-repeat,ng-repeat,angularjs-filter
I am learning Angular so I created casual To do app. Custom filter works on localhost while on hosting it doesnt. I don't get any error messages and data doesn't show. If i remove taskPriority:this from li data shows which means on the server everything is ok but then, of...

How to make this filter better

angularjs,angularjs-ng-repeat,angularjs-filter
I want to make the ng-repeat run for the courses chosen from the select input. For this purpose I am using a customized filter. Whenever arrayFilter is undefined or when arrayFilter is empty, i have hardcoded the arrayFilter to all the values, else arrayFilter consist of the values chosen from...

Filter numbers with parentheses in Angular JS

angularjs,datatables,angularjs-filter
I have a json data like this [{name:"abc", count:"(10)", {name:"xyz", count:"(20)"}, {name:"pqr", count:20}] I bind this data using Angular datatables and I now want to sort the count column in the following manner UPDATE In descending it should be as count (20) 20 (10) In ascending it should be as...

Pass array of filters to a directive

angularjs,angularjs-directive,angularjs-filter
I need to do something similar to this, where I want to determine a class from a value inside a ng-repeat inside a directive: <div ng-repeat="value in data"> <div class="value | classFilters[$index]"> </div> </div> The directive must be able to support different filters for different data. So I'm thinking I...

How to write a custom filter that falls back on a native Angular filter

angularjs,angularjs-filter
I'd like to write a custom filter that falls back on a native Angular filter. For example, I have a nullable C# date that I'm passing to my view in MVC, which I'd like to convert to 'MM/dd/yyyy' if it has a value, else, display None. Html: <div>{{ myNullableDate |...

Angularjs ng-repeat filter based on json value

angularjs,angularjs-ng-repeat,angularjs-filter
I have a plunker here - http://plnkr.co/edit/AmoiJi8k000OKA6TNdcz?p=preview I'm using dummy json here - http://myjson.com/4aqlh I want to display the json content in different parts of the page based on a value in the json So the stories with a value of Section: "New" will be displayed in one div and...

Dollars to Cents in AngularJS for Stripe Checkout

angularjs,angularjs-filter,angularjs-templates
So I have a value that is returned from Firebase that looks like this: 143.418 When I run it through angulars currency filter it returns: {{invoice.pricing.graTotal | currency}} //Returns : $143.42 I have integrated Stripe Checkout into my application and it needs values to look like so: 14342 So Without...

AngularJS: how to find objects from an array of objects, given an array of property values in an array, using $filter

javascript,arrays,angularjs,angularjs-filter
Have a set of objects in an array (items array) that have property item_id: [{item_id:1,...},{item_id:2,...}...] Have another array with a set of item_ids: [2, 8, 10] How do I use the $filter of angularjs to get array of objects from items array where item_id matches those in item_ids array....

AngularJS - 2 selects for a range of years. Options in second one have to be greater or equal than first one selected

angularjs,angularjs-filter,angularjs-watch
I have 2 selects where I need to choose a range of years. The year of the second select has to be greater or equal than the first one. So if I select a year in the first select, the second select should change and show just the years greater...

Angular.JS filter items using selected option in select dropdown

json,angularjs,wordpress,filter,angularjs-filter
Using the WP API I am outputting a list of posts onto a page from the JSON file. I am trying to filter these posts using an input field and two selects. Currently I am able to filter the posts through the input field (searchrecipe) when I search for a...

Invalid Geojson Object Angularjs &Leafletjs

angularjs,leaflet,geojson,angularjs-filter
In my project i try to synchronize filters with geojson displayed in table and on map. To achieve this i used angular and previously angular-leaflet-directive, but performance was to slow for my purposes so i decide to make my own directive for leaflet.js. In my case i can pass data...

How to catch null, undefined, blank values with AngularJS filter

javascript,angularjs,if-statement,angularjs-filter
I'm attempting to write a filter for use in a grid that will catch all null, undefined, blank string, or other similar values and display a dash "-". I've written the following so far, but it doesn't catch null values, and I'm wondering if it could be more succinct and...

orderBy filter works only once

javascript,angularjs,angularjs-filter
Trying to sort an array of numbers either in ascending or descending order, by choice of the user. This is my code - Order by: <select ng-model="orderCriteria"> <option value="false">ASC</option> <option value="true">DESC</option> </select> <table border="2"> <th>Number</th> <tr ng-repeat="num in [1, 5, 3, 6, 45, 20, 7, 2] | filter: query |...

Filter multiple object properties together in AngularJS

angularjs,angularjs-filter
I have an object in my controller var app = angular.module('myApp', []); app.controller('myCtrl', function($scope) { $scope.names = [{"Name":"Alfreds Futterkiste","City":"Berlin","Country":"Germany"}, {"Name":"Ana Trujillo Emparedados y helados","City":"México D.F.","Country":"Mexico"}, {"Name":"Antonio Moreno Taquería","City":"México D.F.","Country":"Mexico"}, {"Name":"Around the Horn","City":"London","Country":"UK"}, {"Name":"B's Beverages","City":"London","Country":"UK"}]; }); I want to filter Name, Country at the same time....

AngularJS - Pass parameter to filter in custom directive

angularjs,angularjs-directive,angularjs-filter
I'm trying to pass a parameter (true, false) to a filter in a custom directive, but I always get an 'undefined'. <job jobs="jobs" activateFilter="activateFilter"> In a controller (outside of customDirective): $scope.activateFilter = true; This is the directive: ... restrict: 'E', scope: { jobs: "=jobs", activateFilter: "=activateFilter" }, controller: controller, templateUrl:...

Angular custom orderBy that combines alphabetical and numerical sorting

javascript,angularjs,angularjs-filter
I have an array as follows (data simplified for the question): var myArray = ['Text 1', 'Text 9', 'Text 10']; Understandbly the regular Angular orderBy yields the below when applied: Text 1 Text 10 Text 9 I am looking for the most elegant way to write a custom orderBy function...

Angular-DataTables custom filter

angularjs,datatable,datatables,angularjs-filter
i am trying to add a custom filter to angular-DataTables with server side processing, which works perfectly with sorting and built in search of datatables. I was following example Angular-DataTables, to build the server side processing and setup the DataTable, in searching around i have found some info but haven't...

Angularjs filter ng-repeat by datepicker

angularjs,datepicker,angularjs-filter
Can someone help me to filter my ng-repeat using datepicker?, I'm not that expert when it comes to these and I'm still in the learning process. I really appreciate your help. Thank you. here is my html: <form style=" text-align: center;"> <div class="row"> <div class="col-xs-6"> <p class="input-group"> <input type="text" class="form-control"...