Search Posts

Category: angularjs-filter

angularjs custom sum filter doesn’t work

im trying to do sum operation on my table Like Item Price abc 10 xyz 20 Ites=>2 Price=>30 For this i wrote simple custome filter .filter(‘SumOfAmt’, function () { return function (data, key) { if (angular.isUndefined(data) || angular.isUndefined(key)) return 0; var sum = 0; angular.forEach(data, function (value) { sum = sum + parseInt(value[key]); Html code <form name=”form1″ ng-submit=”SaveDb(form1.$valid)” novalidate> <b>cost</b><input type=”number” ng-model=”cost” required /> </form> This is my Table when user enter in form it […]

How to filter an nested object array by value in angular expression?

I’m using an ng-repeat where each object (item) is as below: { “properties”: [ {“value”:”started”,”key”:”status”}, {“value”:”somename”,”key”:”name”}, {“value”:”10″,”key”:”age”}, ] } How do I get the value corresponding to key ‘status’ I have tried: <span class=”badge”>{{[‘value’] | filter:{item:{properties:{key:’status’}}}}}</span> but no luck. Thanks, Rohith Source: AngularJS

AngularJS filter field according to values of an array

I have an Array and this array contains some Id’s. I would like to filter my result according to Id’s. For Example please see the below code snippet. How can I show the records which ‘StatusId’ located in the ‘ids’ array? According to my example, I want to list only: AAA BBB CCC <html> <script src=””></script> <script src=””></script> <script> angular.module(‘myApp’, []).controller(‘ctrl’, function ($scope) { $scope.ids = [{ “id”: 1 }, { “id”: 2 }, { […]

Formating dates in AngularJS ng-repeat directive from json array

I’m obtaining a response in json format from laravel application like below: [{“id”:11,”name”:”test”,”description”:”adddas”,”isDone”:false,”created_at”:{“date”:”2017-09-06 12:23:23.000000″,”timezone_type”:3,”timezone”:”UTC”}},{“id”:12,”name”:”test2″,”description”:”asdasdsa”,”isDone”:false,”created_at”:{“date”:”2017-09-13 06:23:22.000000″,”timezone_type”:3,”timezone”:”UTC”}},{“id”:13,”name”:”task12321″,”description”:”jakis tam testowy task”,”isDone”:false,”created_at”:{“date”:”2017-09-03 18:44:57.000000″,”timezone_type”:3,”timezone”:”UTC”}},{“id”:14,”name”:”task12321″,”description”:”jakis tam testowy task”,”isDone”:false,”created_at”:{“date”:”2017-09-03 20:23:58.000000″,”timezone_type”:3,”timezone”:”UTC”}},{“id”:15,”name”:”task12321″,”description”:”jakis tam testowy task”,”isDone”:false,”created_at”:{“date”:”2017-09-03 20:45:35.000000″,”timezone_type”:3,”timezone”:”UTC”}}] I’m trying to format these data in Angular js in ng-repeat directive in way like below: <div class=”table-responsive”> <table class=”table table-hover”> <thead> <tr> <th>name</th> <th>Created at</th> </tr> </thead> <tbody> <tr ng-repeat=”task in tasks”> <td>{{}}</td> <td>{{ | date:’yyyy-MM-dd HH:mm:ss’ }}</td> </tr> </tbody> </table> </div> The problem is with […]