Answer the question
In order to leave comments, you need to log in
How to filter a list of elements?
Hello!
There is such an array in php
$arResult = array();
$arResult['applications_type'] = array(
array(
'id' => 65,
'name' => 'Документы'
),
array(
'id' => 89,
'name' => 'Обучение'
),
array(
'id' => 111,
'name' => 'Командировку'
)
);
for($i = 0; $i <= 5; $i++)
{
$arResult['applications'][65][$i] = array(
'id' => $i,
'name' => 'Справка с места работы',
'task' => array(
'id' => $i,
'name' => 'Заполните форму',
'link' => ''
),
'actions' => array(
array(
'label' => 'Подробнее',
'link' => ''
),
array(
'label' => 'Остановить',
'link' => ''
)
)
);
$arResult['applications'][89][$i] = array(
'id' => $i,
'name' => 'Завка на обучение',
'task' => array(
'id' => $i,
'name' => 'Заполните форму',
'link' => ''
),
'actions' => array(
array(
'label' => 'Подробнее',
'link' => ''
),
array(
'label' => 'Остановить',
'link' => ''
)
)
);
$arResult['applications'][111][$i] = array(
'id' => $i,
'name' => 'Завка на командировку',
'task' => array(
'id' => $i,
'name' => 'Заполните форму',
'link' => ''
),
'actions' => array(
array(
'label' => 'Подробнее',
'link' => ''
),
array(
'label' => 'Копировать',
'link' => ''
),
array(
'label' => 'Продлить',
'link' => ''
),
array(
'label' => 'Сократить',
'link' => ''
),
array(
'label' => 'Изменить',
'link' => ''
),
array(
'label' => 'Удалить',
'link' => ''
),
array(
'label' => 'Остановить',
'link' => ''
)
)
);
}
<div class="block_search_app">
<span class="app_name">Заявки на </span>
<select class="select_app">
<option value="{{type.id}}" ng-repeat="type in types">{{type.name}}</option>
</select>
</div>
<table class="table_applications" id="TableApplications">
<thead>
<th class="app name">Название заявки</th>
<th class="app status">Статус заявки</th>
<th class="app task">Задание</th>
</thead>
<tbody>
<tr class="bid" ng-repeat="doc in applications | filter">
<td class="name">{{doc.name}}</td>
<td class="status">
<span class="status work"></span>
В работе
</td>
<td class="task">
<a href="{{doc.task.link}}" class="task_link"><b>{{doc.task.name}}</b></a>
</td>
</tr>
Answer the question
In order to leave comments, you need to log in
It is not clear how the array types and applications are related.
If each application element had a type field equal to one of the values of the types array, then there would be such a solution.
<div class="block_search_app">
<span class="app_name">Заявки на </span>
<select ng-model="type" class="select_app">
<option value="">Все</option>
<option value="{{type.id}}" ng-repeat="type in types">{{type.name}}</option>
</select>
</div>
<table class="table_applications" id="TableApplications">
<thead>
<th class="app name">Название заявки</th>
<th class="app status">Статус заявки</th>
<th class="app task">Задание</th>
</thead>
<tbody>
<tr class="bid" ng-repeat="doc in applications | filter:type">
<td class="name">{{doc.name}}</td>
<td class="status">
<span class="status work"></span>
В работе
</td>
<td class="task">
<a href="{{doc.task.link}}" class="task_link"><b>{{doc.task.name}}</b></a>
</td>
</tr>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question