Comportamiento extraño de la tabla inteligente AngularJS con objetos anidados y búsqueda st
Estoy tratando de implementar el módulo Smart Table en mi aplicación AngularJS. Preferiría esto sobre otros principalmente porque los otros parecían requerir mucho código repetitivo en mi controlador y me gusta mantener mis controladores lo más SECOS posible. Pero estoy abierto a otros módulos que pueden lograr lo mismo sin repetitivo.
Funciona muy bien cuando se trata de una matriz directa de objetos, pero si algunos de esos objetos tienen objetos anidados, el filtrado y la clasificación tienen un comportamiento extraño.
Esto requerirá algunas explicaciones, así que tengan paciencia conmigo.
En primer lugar, aquí está mi conjunto de objetos anidados (abreviados para facilitar la lectura aquí):
$scope.products = [
{
'display': 'Live',
'name': 'LC1D09',
'category': 'Motor Control',
'subcategory': 'Contactor',
'manufacturer': 'Telemecanique',
'specs': {
'phase': 3,
'poles': 3
},
'new': {
'price': 158.95
},
'refurbished': {
'price': 145
},
'onlineStores': {
'amazon': true,
'ebay': false
},
'isCool': true
},
{
'display': 'Pending',
'name': 'FA32020',
'category': 'Circuit Breaker',
'subcategory': 'Molded Case',
'manufacturer': 'Square D',
'specs': {
'phase': 1,
'poles': 2
},
'new': {
'price': 217.79
},
'refurbished': {
'price': 192.82
},
'onlineStores': {
'amazon': true,
'ebay': true
},
'isCool': false
}
];
$scope.displayedProducts = $scope.products;
Aquí está mi HTML:
<table st-table="displayedProducts" st-safe-src="products" class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th st-sort="name">Name</th>
<th st-sort="category">Category</th>
<th>Subcategory</th>
<th>Manufacturer</th>
<th>New Price</th>
<th>Refurb. Price</th>
<th>Display</th>
<th>Specs</th>
<th>Cool</th>
</tr>
<tr>
<th><input st-search="'name'" placeholder="" class="input-sm form-control" type="search"/></th>
<th><input st-search="'category'" placeholder="" class="input-sm form-control" type="search"/></th>
<th><input st-search="'subcategory'" placeholder="" class="input-sm form-control" type="search"/></th>
<th><input st-search="'manufacturer'" placeholder="" class="input-sm form-control" type="search"/></th>
<th><input st-search="new.price" placeholder="" class="input-sm form-control" type="search"/></th>
<th><input st-search="refurbished.price" placeholder="" class="input-sm form-control" type="search"/></th>
<th><input st-search="'display'" placeholder="" class="input-sm form-control" type="search"/></th>
<th><input st-search="'specs'" placeholder="" class="input-sm form-control" type="search"/></th>
<th>
<select st-search="onlineStores.ebay" class="form-control">
<option value=""></option>
<option value="true">Yes</option>
<option value="false">No</option>
</select>
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="product in displayedProducts">
<td>{{product.name}}</td>
<td>{{product.category}}</td>
<td>{{product.subcategory}}</td>
<td>{{product.manufacturer}}</td>
<td>${{product.new.price | number : 0}}</td>
<td>${{product.refurbished.price | number : 0}}</td>
<td>{{product.display}}</td>
<td>{{product.specs}}</td>
<td>{{product.onlineStores.ebay}}</td>
</tr>
</tbody>
</table>
EntoncesTodo esto funciona bien si mi matriz no tiene objetos anidados. Pero con los objetos anidados (p. Ej.st-search="new.price"
Recibo los siguientes problemas (ver la captura de pantalla):
True
mostrará todos los registros, peroFalse
mostrará solo el registro cuyo valor esFalse
.¿Alguien más descubrió cómo lidiar con los objetos anidados y el módulo de mesa inteligente?