R
R
Roman Skobtsov2015-06-05 21:04:54
JavaScript
Roman Skobtsov, 2015-06-05 21:04:54

How to implement data return in angularjs?

How to implement a search field at the top of the page that filters the content of the active tab, showing only those list items that contain the text typed in the search field. If there are no such elements, the "Show all" link is shown, by clicking on which the search field is cleared and all elements of the corresponding list are shown. But the link-block list consists of several tabs,
for example, the first tab with books, after the tab associated with the authors of books, etc. .that is, binding data that is taken from the angular file.
I can't solve this problem

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
Pavel Kononenko, 2015-06-05
@premas

input type="text" ng-model="search.title"

.tab ng-click="activeTab='books'"
.tab ng-click="activeTab='authors'"
.tab ng-click="activeTab='etc'"

ul
  li ng-repeat="item in data[activeTab] | filter:search"
    | {{item.title}}

Then tune yourself.

V
Valentin Dubrovsky, 2015-06-05
@matroskin13

https://docs.angularjs.org/api/ng/filter/filter

S
Sergey, 2015-06-05
Protko @Fesor

but for God's sake, don't use the filter filter for this.
filters have changed - the controller filters the collection result - display the collection. No magic, no filters in views, everything is as primitive and simple as possible.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question