D
D
Dmitry Sokolov2016-06-20 15:23:30
Angular
Dmitry Sokolov, 2016-06-20 15:23:30

Loading data + filtering by them in AngularJS. How to reset the controller?

Good afternoon!
Tell me how to properly load the goods and filter by them.
Separately, everything works, but together there is a problem.
in the controller I output it like this:

ng-repeat='good in goods | limitTo:rowLimit | filter:searchText'

On the buttons of the filters, it is done like this
ng-click="searchText.priceType = 'Эконом'"
. In the controller it is indicated.
$scope.rowLimit = 5;
In the application, the LOAD button.
ng-click="rowLimit = rowLimit + 2"
The problem is that the filter works correctly if the rowLimit is equal to the entire number of goods. That is, I suspect that it is all then in the scope and the filter works as it should.
But then the whole product is displayed on the page. I need to display several positions and call on the button, but for the filter to work correctly.
I thought to add to the filter
ng-click="searchText.priceType = 'Эконом'; rowLimit = 500;",
but that doesn't work. Apparently you need to somehow reboot the controller.
Tell me how to get out of the situation?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Николай, 2016-06-20
@Dm-Sok

Не мучайте разметку, сделайте всё в js, а для вывода используйте только ng-repeat + ng-click на элементах для фильтрации/подгрузки.
P.S.
Ваш вариант должен заработать, если конструкции filter и limit местами поменять.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question