- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当项目详细信息来自另一个 JSON 对象时,是否有任何选项可以使用预先输入搜索项目名称?
演示:http://codepen.io/anon/pen/PGWvmE
其他过滤器和 orderBy 工作正常,但我找不到使用 orderBy 和基于列表中所选项目的过滤器从 typeahead 进行项目搜索的解决方案
angular.module('mytodos', ['ui.bootstrap']).controller('TodoController', function($scope) {
$scope.changeNum = function(itemNum) {
$scope.numPerPage = itemNum;
};
$scope.numsForPage = [5, 10, 25, 50, 100];
$scope.currentPage = 1;
$scope.numPerPage = 5;
$scope.maxSize = 5;
// Sort
$scope.changeSort = function(item) {
$scope.reverse = $scope.reverse = !$scope.reverse;
$scope.sort = item;
};
$scope.filteredTodos = [];
$scope.currentPage = 1;
$scope.numPerPage = 5;
$scope.maxSize = 5;
$scope.expenses = [
{
"id": 1,
"name": "Warren Phillips",
"amount": "37.47",
"date": "12/11/2015",
"item_id": 1,
"model_id": 1,
"description": "blandit. Nam nulla magna, malesuada vel, convallis in, cursus et, eros. Proin ultrices. Duis volutpat nunc sit amet metus. Aliquam erat volutpat. Nulla facilisis. Suspendisse commodo tincidunt nibh. Phasellus nulla. Integer vulputate, risus a ultricies adipiscing, enim mi tempor lorem, eget mollis lectus pede et risus. Quisque libero lacus, varius et, euismod et, commodo at, libero. Morbi accumsan"
}, {
"id": 2,
"name": "Declan Ayala",
"amount": "29.18",
"date": "12/17/2014",
"item_id": 3,
"model_id": 8,
"description": "Integer eu lacus. Quisque imperdiet, erat nonummy ultricies ornare, elit elit fermentum risus, at fringilla purus mauris a nunc. In at pede. Cras"
}, {
"id": 3,
"name": "Ivana Bell",
"amount": "88.53",
"date": "11/20/2014",
"item_id": 3,
"model_id": 6,
"description": "Etiam imperdiet dictum magna. Ut tincidunt orci quis lectus. Nullam suscipit, est ac facilisis facilisis, magna tellus faucibus leo, in lobortis tellus justo sit amet nulla."
}, {
"id": 4,
"name": "Brennan Noel",
"amount": "17.76",
"date": "02/06/2015",
"item_id": 6,
"model_id": 22,
"description": "velit eu sem. Pellentesque ut ipsum ac mi eleifend egestas. Sed pharetra, felis"
}, {
"id": 5,
"name": "Thomas Tran",
"amount": "29.59",
"date": "08/20/2014",
"item_id": 3,
"model_id": 7,
"description": "nisl sem, consequat nec, mollis vitae, posuere at, velit. Cras lorem lorem, luctus ut, pellentesque eget, dictum placerat, augue. Sed molestie. Sed id risus quis diam luctus lobortis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Mauris ut quam vel sapien imperdiet ornare."
}, {
"id": 6,
"name": "Tucker Bolton",
"amount": "66.69",
"date": "12/09/2014",
"item_id": 4,
"model_id": 14,
"description": "et risus. Quisque libero lacus, varius et, euismod et, commodo at, libero. Morbi accumsan laoreet ipsum. Curabitur consequat, lectus sit amet luctus vulputate, nisi sem semper erat, in consectetuer ipsum nunc id enim. Curabitur massa. Vestibulum accumsan neque et nunc. Quisque ornare tortor at risus. Nunc ac sem ut dolor dapibus gravida. Aliquam tincidunt, nunc ac mattis ornare, lectus ante dictum mi, ac mattis velit justo nec ante. Maecenas mi felis, adipiscing fringilla, porttitor vulputate, posuere vulputate, lacus. Cras interdum."
}, {
"id": 7,
"name": "Medge Mullen",
"amount": "23.78",
"date": "10/17/2015",
"item_id": 4,
"model_id": 12,
"description": "dictum mi, ac mattis velit justo nec ante. Maecenas mi felis, adipiscing fringilla, porttitor vulputate, posuere vulputate, lacus. Cras interdum. Nunc sollicitudin commodo ipsum. Suspendisse non leo. Vivamus nibh dolor, nonummy ac, feugiat non, lobortis quis, pede. Suspendisse dui. Fusce diam nunc, ullamcorper eu, euismod ac, fermentum vel, mauris. Integer sem elit, pharetra ut, pharetra sed, hendrerit a, arcu. Sed et"
}, {
"id": 8,
"name": "Morgan Merritt",
"amount": "54.09",
"date": "04/10/2016",
"item_id": 2,
"model_id": 4,
"description": "Nulla facilisis. Suspendisse commodo tincidunt nibh. Phasellus nulla. Integer vulputate, risus a ultricies adipiscing, enim mi tempor lorem, eget mollis lectus pede et risus. Quisque libero lacus, varius et, euismod et,"
}, {
"id": 9,
"name": "Janna Casey",
"amount": "22.61",
"date": "08/05/2015",
"item_id": 1,
"model_id": 1,
"description": "eros turpis non enim. Mauris quis turpis vitae purus gravida sagittis. Duis gravida. Praesent eu nulla at sem molestie sodales. Mauris blandit enim consequat purus. Maecenas libero est, congue a, aliquet vel, vulputate eu, odio. Phasellus at augue id ante dictum"
}, {
"id": 10,
"name": "Buffy Best",
"amount": "59.98",
"date": "05/06/2015",
"item_id": 5,
"model_id": 15,
"description": "lacus vestibulum lorem, sit amet ultricies sem magna nec quam. Curabitur vel lectus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec dignissim magna a tortor. Nunc commodo auctor velit. Aliquam nisl. Nulla eu neque pellentesque massa lobortis ultrices. Vivamus rhoncus. Donec est. Nunc ullamcorper, velit in aliquet lobortis, nisi nibh lacinia orci, consectetuer euismod est arcu ac orci. Ut semper pretium neque. Morbi quis urna."
}, {
"id": 11,
"name": "Brielle Newman",
"amount": "52.26",
"date": "04/16/2016",
"item_id": 4,
"model_id": 18,
"description": "placerat, augue. Sed molestie. Sed id risus quis diam luctus lobortis."
}, {
"id": 12,
"name": "Julie James",
"amount": "6.38",
"date": "08/15/2014",
"item_id": 3,
"model_id": 6,
"description": "placerat, orci lacus vestibulum lorem, sit amet ultricies sem magna nec quam. Curabitur vel lectus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec dignissim magna a tortor. Nunc commodo auctor velit. Aliquam nisl. Nulla eu neque"
}, {
"id": 13,
"name": "Shaine Barnett",
"amount": "0.04",
"date": "09/29/2014",
"item_id": 5,
"model_id": 20,
"description": "laoreet, libero et tristique pellentesque, tellus sem mollis dui, in sodales elit erat vitae risus. Duis a mi fringilla mi lacinia mattis. Integer eu lacus. Quisque imperdiet, erat nonummy ultricies ornare, elit elit fermentum risus, at fringilla purus mauris a nunc. In at pede. Cras vulputate velit eu sem. Pellentesque ut ipsum ac mi eleifend egestas. Sed"
}, {
"id": 14,
"name": "Genevieve Underwood",
"amount": "50.71",
"date": "09/24/2015",
"item_id": 6,
"model_id": 22,
"description": "consequat auctor, nunc nulla vulputate dui, nec tempus mauris erat eget ipsum. Suspendisse sagittis. Nullam vitae diam. Proin dolor. Nulla semper"
}, {
"id": 15,
"name": "Adam Villarreal",
"amount": "18.48",
"date": "04/06/2016",
"item_id": 2,
"model_id": 5,
"description": "nisl. Maecenas malesuada fringilla est. Mauris eu turpis. Nulla aliquet. Proin velit. Sed malesuada augue ut lacus. Nulla tincidunt, neque vitae semper egestas, urna justo faucibus lectus, a sollicitudin orci sem eget massa. Suspendisse eleifend. Cras sed leo. Cras vehicula aliquet libero. Integer in magna. Phasellus dolor elit, pellentesque a, facilisis non, bibendum sed, est. Nunc laoreet lectus quis massa. Mauris"
}
];
$scope.theItems = {
1: {'name': 'TV', 'models': [1] },
2: {'name': 'Radio', 'models': [2,3,4,5] },
3: {'name': 'Mobile', 'models': [6,7,8,9,10,11] },
4: {'name': 'Tablet', 'models': [12,13,14,15,16] },
5: {'name': 'Camera', 'models': [17,18,19,20,21] },
6: {'name': 'Speaker', 'models': [22,23,24] }
}
$scope.theModels = {
1: {'name': 'Toshiba', 'make': 1},
2: {'name': 'Samsung', 'make': 2},
3: {'name': 'Sony', 'make': 2},
4: {'name': 'Panasonic', 'make': 2},
5: {'name': 'Akai', 'make': 2},
6: {'name': 'iPhone', 'make': 3},
7: {'name': 'Lumia', 'make': 3},
8: {'name': 'Galaxy', 'make': 3},
9: {'name': 'Note II', 'make': 3},
10: {'name': 'Note IV', 'make': 3},
11: {'name': '159 Sportwagon', 'make': 3},
12: {'name': 'Pixel C', 'make': 4},
13: {'name': 'Surface Pro', 'make': 4},
14: {'name': 'iPad Air', 'make': 4},
15: {'name': 'Xperia', 'make': 4},
16: {'name': 'Galaxy S2', 'make': 4},
17: {'name': 'Sony A7R II', 'make': 5},
18: {'name': 'Nikon D500', 'make': 5},
19: {'name': 'Fuji X-T10', 'make': 5},
20: {'name': 'RX100 III', 'make': 5},
21: {'name': 'Boom 2', 'make': 5},
22: {'name': 'Fugoo', 'make': 6},
23: {'name': 'JBL Charge', 'make': 6},
24: {'name': 'JBL Xtreme', 'make': 6},
}
$scope.theItemsArray = $.map($scope.theItems, function(val, index) {
val.key = index;
return [val];
});
$scope.theModelArray = $.map($scope.theModels, function(val, index) {
val.key = index;
return [val];
});
}).filter('pagination', function() {
return function(input, currentPage, pageSize) {
if(angular.isArray(input)) {
var start = (currentPage-1)*pageSize;
var end = currentPage*pageSize;
return input.slice(start, end);
}
};
});
.box {
border: 1px solid #DDD;
padding: 10px;
position: relative;
background: #FFF;
margin: 0 0 10px;
}
.tab-content > .tab-pane > .box {
border-top: none;
}
.tab-content > .box {
border-top: none;
}
select.pagiantion {
width: auto;
display: inline-block;
}
.box {
th {
cursor: pointer;
}
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular.min.js"></script>
<script src="https://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-2.1.3.min.js"></script>
<div ng-app="mytodos" ng-controller="TodoController">
<div class="container">
<hr />
<uib-tabset>
<uib-tab>
<uib-tab-heading>Statement</uib-tab-heading>
<div class="box">
<h1>Todos</h1>
<h4>{{expenses.length}} total</h4>
<div class="row">
<div class="col-md-6">
<label for="">Show
<select class="form-control pagiantion" ng-model="numPerPage" ng-options="numPage for numPage in numsForPage" ng-change="changeNum(numPerPage);"></select>
entries
</label>
</div>
</div>
<table class="table table-hover table-responsive table-bordered">
<thead>
<tr>
<th ng-click="changeSort('name')">Name <span class="glyphicon pull-right" ng-class="sort == 'name' ? (reverse ? 'glyphicon-sort-by-attributes-alt' : 'glyphicon-sort-by-attributes') : 'glyphicon-sort' "></span></th>
<th ng-click="changeSort('amount')">Amount <span class="glyphicon pull-right" ng-class="sort == 'amount' ? (reverse ? 'glyphicon-sort-by-attributes-alt' : 'glyphicon-sort-by-attributes') : 'glyphicon-sort' "></span></th>
<th ng-click="changeSort('date')">Date <span class="glyphicon pull-right" ng-class="sort == 'date' ? (reverse ? 'glyphicon-sort-by-attributes-alt' : 'glyphicon-sort-by-attributes') : 'glyphicon-sort' "></span></th>
<th ng-click="changeSort('item')">Item <span class="glyphicon pull-right" ng-class="sort == 'date' ? (reverse ? 'glyphicon-sort-by-attributes-alt' : 'glyphicon-sort-by-attributes') : 'glyphicon-sort' "></span></th>
<th ng-click="changeSort('item')">Model <span class="glyphicon pull-right" ng-class="sort == 'date' ? (reverse ? 'glyphicon-sort-by-attributes-alt' : 'glyphicon-sort-by-attributes') : 'glyphicon-sort' "></span></th>
</tr>
<tr>
<th>
<input
type="text"
class="form-control"
placeholder="Name"
ng-model="filterlist.name"/>
</th>
<th>
<input
type="text"
class="form-control"
placeholder="Amount"
ng-model="filterlist.amount"/>
</th>
<th>
<input
type="text"
class="form-control"
placeholder="Date"
ng-model="filterlist.date"/>
</th>
<th>
<input
type="text"
class="form-control"
ng-model="filterlist.item"
uib-typeahead="item as item.name for item in theItemsArray | filter:{name:$viewValue} | limitTo:8"
>
</th>
<th>
<input
type="text"
class="form-control"
ng-model="filterlist.model"
uib-typeahead="model as model.name for model in theModelArray | filter:{name:$viewValue} | limitTo:8"
>
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="expense in filteredlist = (expenses | filter:filterlist) | orderBy:sort:reverse | pagination: currentPage : numPerPage">
<td>{{expense.name}}</td>
<td>{{expense.amount}}</td>
<td>{{expense.date}}</td>
<td>{{theItems[expense.item_id].name}}</td>
<td>{{theModels[expense.model_id].name}}</td>
</tr>
</tbody>
</table>
<div class="clearfix" ng-show="expenses.length > numPerPage">
<ul uib-pagination
class="pagination-sm pull-right"
ng-model="currentPage"
max-size="maxSize"
total-items="filteredlist.length"
ng-hide="filteredlist.length < numPerPage"
ng-change="pageChanged()"
max-size="5"
items-per-page="numPerPage"
boundary-links="true"
previous-text="‹"
next-text="›"
first-text="«"
last-text="»"
></ul>
</div>
</div>
</uib-tab>
</uib-tabset>
</div>
</div>
最佳答案
类似的思路:先修改数据:
function preprocess(expenses) {
for (var i = 0; i < expenses.length; i++) {
var expense = expenses[i];
expense.item = $scope.theItems[expense.item_id].name;
expense.model = $scope.theModels[expense.model_id].name;
expenses[i] = expense;
}
return expenses;
}
$scope.expenses = preprocess($scope.expenses);
$scope.theItemsArray = $.map($scope.theItems, function(val, index) {
return [val.name];
});
$scope.theModelArray = $.map($scope.theModels, function(val, index) {
return [val.name];
});
然后修改html:
uib-typeahead="item for item in theItemsArray | filter:$viewValue | limitTo:8"
uib-typeahead="model for model in theModelArray | filter:$viewValue | limitTo:8"
<th ng-click="changeSort('model')">Model
<td>{{expense.item}}</td>
<td>{{expense.model}}</td>
关于javascript - Angular UI Bootstrap Typeahead 不适用于过滤器和 orderBy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39650192/
情况我想使用 ui-date 在我的应用程序中设置/编辑日期。我使用最新稳定版本的 Angular、Angular-UI、JQuery-UI 等。 问题一旦使用日期选择器选择了日期,我的模型中的日期将
编辑: jQuery UI 可选择小部件内置了一个回调,stop,我需要知道如何以编程方式触发此事件。 (措辞不佳)我已将事件监听器附加到 jQuery UI Selectable Widget 。如
我正在尝试建立一个下一个JS与尾风用户界面提供的反应组件的网络应用程序。顺风用户界面是在幕后使用无头用户界面。。默认情况下,Next JS将构建服务器端组件,除非您在页面顶部添加“使用客户端”。不幸的
我正在尝试建立一个下一个JS与尾风用户界面提供的反应组件的网络应用程序。顺风用户界面是在幕后使用无头用户界面。。默认情况下,Next JS将构建服务器端组件,除非您在页面顶部添加“使用客户端”。不幸的
我正在尝试应用这个 SlickGrid 示例: http://mleibman.github.com/SlickGrid/examples/example4-model.html 到我自己的网络项目。
我想整理我的 Schemas为我的实体类生成,DTO 类位于 Springdoc ui . 我可以对 tags 进行排序和 operations通过以下配置 yml文件,但我的模式不是按排序顺序排列的
有谁知道阻止 ui-sref 重新加载状态的方法吗? 我无法通过“$stateChangeStart”事件执行此操作,因为 ui-sref 仅更改参数而不更改状态名称。 我的左边是书单,左边是书的详细
我正在 jquery ui 对话框中使用 jquery ui 自动完成小部件。当我输入搜索文本时,文本框缩进(ui-autocomplet-loading)但不显示任何建议。 var availabl
我正在尝试将 Kendo UI MVVM 框架与 Kendo UI 拖放机制结合使用;但我很难找到如何将数据从 draggable 对象中删除。 我的代码是这样的...... var viewMode
Kendo UI Web 和 Kendo UI Core 之间有什么区别 https://www.nuget.org/packages/KendoUIWeb http://www.nuget.org/
我正在尝试将 Kendo UI MVVM 框架与 Kendo UI 拖放机制结合使用;但是我很难找到如何从 draggable 对象中删除数据。 我的代码是这样的…… var viewModel =
使用 Angular JS - UI 路由器,我需要从我的父 View project.details 到我的 subview project.details.tasks 进行通信。我的 subvie
KendoUI 版本 2013.3.1119使用 Kendo MVVM 我有一个我构建的颜色选择器,它使用平面颜色选择器和使用调色板的颜色选择器。它们都可以正常运行,但平面颜色选择器的布局已关闭, s
我在非 UI 线程上,我需要创建并显示一个 SaveDialog。但是当我尝试显示它时:.ShowDialog() 我得到: "An unhandled exception of type 'Syst
我正在试验 jquery-ui 并查看和克隆一些示例。在一个示例(自动完成的组合框)中,我看到一个带有 ui-widget 类的 anchor (a) 元素,它与包含的 css 文件中的 .ui-wi
我需要返回一个 UI 列表,我用这个方法: getList(): Observable { return this.httpClient.get("/api/listui").pipe
我有 ui-grids在 angular-ui-tabs ,它们位于 ng-if 中以避免呈现问题。如果有更多数据并且网格进入滚动模式,则单击选项卡时数据会完全消失。我相信这是一个 ui-grids-
这似乎是一个通用的问题,与其他几个 React 开源框架相比,我真的很喜欢 Material ui 的可扩展性。 问题 “@material-ui/core”和“@material-ui/lab”中的
我有一个根页面(index.html),带有侧边栏(“菜单”)和主要内容 div(“主”),因此有两个 ui-view div - 一个称为“菜单”,一个称为“主”。 当主要内容区域有网站列表 (/s
有人在http://jsfiddle.net/hKYWr/上整理了一个很好的 fiddle 。关于使用 angular-ui 和 jqueryui sortable 来获得良好的可排序效果。 如何在两
我是一名优秀的程序员,十分优秀!