app.js
angular .module('app',[]) .controller("PostsCtrl", function($scope, $rootScope, $http) { $http.get('price.json').success(function(data, status, headers, config) { $scope.posts = data; }) $scope.val = 1; $scope.kurs = 21; $scope.check = true; $scope.all = {}; } ); angular .module('app') .filter('total', function() { return function(price) { var newprice = {}; var result = 0; for (var key in price) { newprice = price[key].replace(',', ''); result += parseFloat(newprice.replace(',', '')); } result = String(result).replace(/(\d)(?=(\d{3})+([^\d]|$))/g, '$1 '); return result; }; });
index.html
<div class="uk-margin-large-top" ng-controller="PostsCtrl"> <div class="uk-text-right">Быстрый поиск по слову или фразе <input type="text" placeholder="демонтаж" ng-model="query" /> </div> <table class="uk-table uk-table-hover uk-table-condensed"> <thead> <tr> <th class="uk-text-center">№</th> <th>Наименование работ</th> <th class="uk-text-center">Ед. изм.</th> <th>Цена</th> </tr> </thead> <tbody ng-repeat="price in posts | filter:query"> <tr> <th colspan="4"> <h2>{{ price.category }}</h2> </th> </tr> <tr ng-repeat="datafields in price.datafields | filter:query"> <td class="{{check}}"> <input ng-model="check" type="checkbox" /> {{$index + 1}}</td> <td class="{{check}}">{{ datafields.name }}</td> <td class="{{check}}"> <input ng-model="val" ng-disabled="!check" ng-pattern="/^\d+$/" class="{{check}} number-pole" value="1" type="number" /> {{ datafields.ed }}</td> <td class="{{ all[datafields.name] = (check) ? (datafields.cost * kurs * val | number: 0) : zero }} </td> </tr> </tbody> <tfoot> <tr> <th style="border: 0" colspan="2"></th> <th colspan="2"> <br /> Общая сумма: <h2>{{ all | total | number: 3 }}</h2></th> </tr> </tfoot> </table> </div>