angularjs-filter

use array in custom filter

空扰寡人 提交于 2020-01-06 18:10:09
问题 I created an array that has the following format... $scope.myArr = [arg1, arg2]; Now I want to create a custom filter that will take the array as a parameter and compare to another array, for example I want to use it as so... <div class="form-container" ng-repeat="formblock in forms | filter:dateFilter(myArr)"> This way every formblock will be compared to the array, so if formblock.date has either arg1 or arg2 then these will show, otherwise hide everything else. Is this possible? 回答1: Your

Filter multiple object properties together in AngularJS

喜欢而已 提交于 2020-01-05 23:49:35
问题 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

is there a way to update filter with async data

二次信任 提交于 2020-01-04 13:51:08
问题 I had build the next angular filter: App.filter('cur2symbol', ['CurrenciesService', function (CurrenciesService) { return function (input, iso) { input = input || ''; iso = iso || 'ILS'; var symbol= CurrenciesService.getCurrencySymbolByIso(iso); return symbol+input; }; }]) the meaning of this filter is to get currency iso code and convert is to symbol for examle: the next code {{200|cur2symbol:"ILS"}} will output ₪200 . My problem is that the CurrenciesService service is Async, so the filter

Why are my ng-repeat items not filtering as expected here?

我是研究僧i 提交于 2020-01-04 13:44:46
问题 Plnkr: http://plnkr.co/edit/Q34J9szbLeGgc4jkcNUM?p=preview I have a simple Array called tags, which contains 4 objects with a tweets value and vol value. When I click the Order by Tweets , or Order by Vol buttons I expect the numbers to make sense, like going from high to low or low to high, but the numbers are out of order. Markup: <div class="sidebar" ng-controller="sidebar"> <header class="my-header"> <button ng-click="reOrderByTweets()">Order by Tweets</button> <button ng-click=

Why are my ng-repeat items not filtering as expected here?

烈酒焚心 提交于 2020-01-04 13:43:23
问题 Plnkr: http://plnkr.co/edit/Q34J9szbLeGgc4jkcNUM?p=preview I have a simple Array called tags, which contains 4 objects with a tweets value and vol value. When I click the Order by Tweets , or Order by Vol buttons I expect the numbers to make sense, like going from high to low or low to high, but the numbers are out of order. Markup: <div class="sidebar" ng-controller="sidebar"> <header class="my-header"> <button ng-click="reOrderByTweets()">Order by Tweets</button> <button ng-click=

Angular JS - Creating a filter to compare 2 arrays

折月煮酒 提交于 2020-01-02 07:21:08
问题 I am developing a search page for an application. I have searched a lot at google, but I can't find anything than fragmented information about filters. What I need is a list of checkboxes containing certain lists of elements (like in the example, languages). I had put a filter for ordering, for the name of the client, but I want to add filters to auxiliar tables like (as I said) languages. Clients: $scope.clientes = [ { 'id': '3', 'name': 'Susana', 'surname': 'Rodríguez Torrón', 'languages':

AngularJS: Should I use a filter to convert integer values into percentages?

余生长醉 提交于 2020-01-01 08:35:08
问题 I need to collect a rate of change - in percentages - from my application's users. Here is the text input I am using: <label for="annual-change" class="pt-underline"> I am anticipating <input id="annual-change" ng-model="calc.yrChange" type="text" placeholder="0" /> % of growth annually.<br><br> </label> Now what I want is to use a filter that takes the integer amount that the user inputs and convert it to a percentage by multiplying it by 0.01 or dividing it by 100 before I send it to the

angularjs filter based on matching values in nested array

允我心安 提交于 2019-12-29 09:21:52
问题 Here is my code. Please run the script to see how it works : var app = angular.module('myApp', []); app.controller('listdata', function($scope, $http) { var data = [{ "name": "John", "queue": [{ "number": "456", "status": "Unavailable" }, { "number": "111", "status": "Unavailable" }, { "number": "201", "status": "Paused" }], "phone": "7411173737" }, { "name": "George", "queue": [{ "number": "111", "status": "Paused" }, { "number": "456", "status": "Unavailable" }], "phone": "8558855858" }, {

Angular limitTo filter's second parameter “begin” does not seem to work in Angular 1.3

隐身守侯 提交于 2019-12-29 08:30:06
问题 I'm trying to do a pagenation feature on an array of users. Using Angularjs 1.3. ng-repeat="user in users | filter: searchText | orderBy: 'lastName' | limitTo:pageSize:startPosition track by user.lanId" I want to use the "begin" parameter, the startPosition variable above, for the start of each page of my list of users. When that did not work, I simplify the task to just trying to limiting to a array of numbers. $scope.numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]; ng-repeat="n in numbers |

AngularJs - bind one ng-model to directive with two inputs

社会主义新天地 提交于 2019-12-29 06:32:08
问题 How to create a range directive which binds to one ng-model and outputs two input fields using a filter (already made). Essentially I've got one direction from model to input working, but the other side from input to model not. How to achieve this? I've got this Html: <div tu-range ng-model="arbitraymodel" /> And a model: var arbitrarymodel = "10/22"; Side note; I created a filter to split those two values: {{ feature.Value | split:\'/\':0}} And this directive: .directive('tuRange', function(