Fix: Memoize would for some reason would crash instead of updating

This commit is contained in:
tanshu 2017-02-13 10:40:30 +05:30
parent a77293e0b2
commit 00b81a7cb9
3 changed files with 9 additions and 10 deletions

View File

@ -27,7 +27,6 @@ var LedgerController = ['$scope', '$routeParams', '$location', 'asDateFilter', '
finishDate = $scope.info.FinishDate;
if (id === $routeParams.id && startDate === $routeParams.StartDate && finishDate === $routeParams.FinishDate) {
Ledger.get({id: id, StartDate: startDate, FinishDate: finishDate}, function (data) {
$scope.doFilter.cache = {};
$scope.info = data;
});
} else {
@ -65,7 +64,7 @@ var LedgerController = ['$scope', '$routeParams', '$location', 'asDateFilter', '
$scope.footer = filtered.Footer;
}, true);
$scope.doFilter = _.memoize(function (hidden, input) {
$scope.doFilter = function (hidden, input) {
var data = angular.copy(input),
debit = 0, credit = 0, running = 0;
@ -97,9 +96,7 @@ var LedgerController = ['$scope', '$routeParams', '$location', 'asDateFilter', '
Running: running
}
};
}, function (hidden) {
return hidden.sort().join(' ');
});
};
$scope.shortcuts = {
'up': function (e) {

View File

@ -1,4 +1,4 @@
<form class="form-horizontal" role=form autocomplete="off">
<form class="form-horizontal" role=form autocomplete="off">
<h2>Ledger</h2>
<div class="form-group">
@ -7,7 +7,8 @@
<div class="col-md-5">
<div class="input-group">
<input class="form-control" id="txtStartDate" type="text" uib-datepicker-popup="dd-MMM-yyyy"
is-open="sdOpen" ng-focus="sdOpen = true" ng-model="info_StartDate" ng-model-options="{getterSetter: true}" />
is-open="sdOpen" ng-focus="sdOpen = true" ng-model="info_StartDate"
ng-model-options="{getterSetter: true}"/>
<span class="input-group-btn">
<button class="btn btn-default"><i class="glyphicon glyphicon-calendar"></i></button>
</span>
@ -16,7 +17,8 @@
<div class="col-md-5">
<div class="input-group">
<input type="text" id="txtFinishDate" class="form-control" uib-datepicker-popup="dd-MMM-yyyy"
is-open="fdOpen" ng-focus="fdOpen = true" ng-model="info_FinishDate" ng-model-options="{getterSetter: true}"/>
is-open="fdOpen" ng-focus="fdOpen = true" ng-model="info_FinishDate"
ng-model-options="{getterSetter: true}"/>
<span class="input-group-btn">
<button class="btn btn-default"><i class="glyphicon glyphicon-calendar"></i></button>
</span>

View File

@ -86,7 +86,7 @@ var RecipeListController = ['$scope', 'recipes', '$location', '$routeParams', '$
});
}
}, 350);
$scope.doFilter = _.memoize(function (q) {
$scope.doFilter = function (q) {
var matches = Tokenizer.parseFilterString(q, $scope.searchInfo),
array = angular.copy($scope.info);
@ -95,7 +95,7 @@ var RecipeListController = ['$scope', 'recipes', '$location', '$routeParams', '$
prod.Prices = $scope.subFilter('Prices.', prod.Prices, matches.q, matches.o);
});
return array;
});
};
$scope.subFilter = function (prefix, arr, q, o) {
q = angular.copy(q);