问题描述
我不得不做出网页上的一些变化我的工作,在此之前,我有一个文本框输入在表上筛选结果,这是code:
I had to make some changes on the webpage i'm working, before this, i had an input textfield to filter results on a table, this was the code:
<p><input type="text" class="form-control" ng-model="search" placeholder="Search..."></p>
和code的表是:
and the code for the table was:
<tr ng-repeat="data in someFile| filter:search | orderBy:'name'">
<td>{{data.state + ', ' + data.city}}</td>
<td> more data goes here etc...</td>
</tr>
这工作就好了,但现在我需要改变选择的 jQuery的输入文本框选择,以获得包含多个过滤器不同的信息。
that worked just fine, but now i need to change the input textfield for jQuery chosen select to get different info with multiple filters.
在code我想是这样的:
The code i tried is this:
<select data-placeholder="Search..." multiple class="control-group chosen-select" chosen id='sl_edo' style="width:200px;">
<optgroup ng-repeat="data in someFile[0].state | orderBy:'name'" label={{data.name}}>
<option value=""> </option>
<option ng-model="search" ng-repeat="city in data.city | orderBy:'name'">
{{city.name}}</option>
</optgroup>
</select>
我知道NG模型code,应在HTML去的选择标签是这样的:
<select ng-model="search" data-placeholder="Search..." etc..
但是,这并不表中的过滤结果,会发生什么情况是,表一片空白,我不知道为什么,除非我不干过滤器的数据可以追溯到表。我能做些什么使code的工作如预期?
but that doesn't filter the results in the table, what happens is that the table goes blank, i have no idea why, unless i quit the filter the data goes back to table. What i can do to make the code work as intended?
修改:我一直在看什么是NG-模型中值=搜索,到目前为止,他们像对待一个这样的数组: [数据1,数据2 ...] (因为我加入了值= {{localidad.nombre}} 上的选项标签),如果我获得一定数值数组中像这样{{搜索[0]}},显示文本通常像这样的数据1 ,但仍然没有过滤表中的结果,表一片空白,什么回事任何想法?
EDIT: i have been watching what are the values in ng-model="search", so far they are treated like an array like this: ["data1","data2"...] (since i added the value={{localidad.nombre}} on the options tag), if i access to certain value in the array like this {{search[0]}}, displays the text normally like this data1, but still not filtering the table results, the table goes blank, any ideas on what's going on?
编辑2 :我偶然在上堆栈溢出的一些问题
How在angularJS 过滤多个值(OR操作),这可能是一个问题?我的意思是过滤器应该是多个。
EDIT 2:i stumbled on some questions on stack overflowHow to filter multiple values (OR operation) in angularJS, this could be an issue? i mean the filters are supposed to be multiple.
推荐答案
原谅我,如果这在不同的切线你以后什么,但我写了一个简单的例子。我认为包括您想以后去什么。驱动已分配给选项标记的价值。
Forgive me if this in a different Tangent to what your after but I wrote a quick example. Which I think covers what your trying to go after.JsFiddle Driven of the Value you have assigned to the option tag.
<p><select data-ng-model="search" >
<option value="NY">New York</option>
<option value="NV">New Vegas</option>
<option value="AL">Alabama</option>
</select>
</p>
<table>
<tr ng-repeat="data in someFile| filter:search | orderBy:'name'" style="border: 1px solid black;" >
<td>{{data.number}}</td>
<td>{{data.state + ', ' + data.city}}</td>
<td> more data goes here etc...</td>
</tr>
<table>
这篇关于jQuery的获选选择不与angularjs纳克模型筛选表上我的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!