How to set input search value that not thought user input on Smart Table? ?? here is my code,When user click the check box,The input field is auto input "Sam", but the table record is not filter. and update.... Here is my code:
<body>
<div class='container' ng-app='smarttabledemo' ng-controller='smarttabledemo'>
<table st-table='data' class='table'>
<thead>
<tr>
<th colspan='999'>
<input name="myCheck[]" type="checkbox" id="myCheck"
st-submit-search ng-model="confirmed" ng-true-value="30"
ng-false-value="1" ng-change="showcheckbox();">
<input st-search="firstName" placeholder="search for firstname"
class="input-sm form-control" type="search"
ng-value="myVar" ng-model="myVar"/>
</th>
</tr>
<tr>
<th st-sort='firstName'>First Name</th>
<th st-sort='lastName'>Last Name</th>
<th st-sort='phone'>Phone Number</th>
<th st-sort='hometown'>Hometown</th>
</tr>
</thead>
<tbody>
<tr st-select-row='row' ng-repeat='row in data'>
<td>{{row.firstName}}</td>
<td>{{row.lastName}}</td>
<td>{{row.phone}}</td>
<td>{{row.hometown}}</td>
</tr>
</tbody>
</table>
</div>
'use strict';
angular.module('smarttabledemo', ['smart-table'])
.run(function() {
console.clear();
})
.controller('smarttabledemo', function($scope) {
$scope.data = [
{ firstName: 'Sam', lastName: 'Evans', phone: 'Not Provide', hometown: 'Anytown, ST' },
{ firstName: 'Saul', lastName: 'Evans', phone: '555-555-1234', hometown: 'Anytown, ST' },
{ firstName: 'Charlie', lastName: 'Anders', phone: '555-555-9876', hometown: 'Springfield, ST' },
{ firstName: 'Jessica', lastName: 'Cortez', phone: 'Not Provide', hometown: 'Springfield, ST' },
{ firstName: 'Amy', lastName: 'Wood', phone: '555-555-1348', hometown: 'Metroville, ST' },
]
$scope.showcheckbox = function () {
var myCheck = document.getElementsByName("myCheck[]");
for (var i = 0; i < myCheck.length; i++) {
if(myCheck[i].checked ){
$scope.myVar = "Sam";
}
}
}
Fiddle Here is my code, thanks My aims is hope user click the checkbox, The table is search about "Sam" record, thx