angular.module("myApp", ['smart-table'])
.constant('POSSIBLE_OPTIONS', ['A', 'B', 'C'])
.controller("MyController", ['POSSIBLE_OPTIONS', function(POSSIBLE_OPTIONS) {
var ctrl = this;
ctrl.display_republish_records = [{
botMainId: "A",
botSet: "HK64604",
botNumber: "786443174705883702"
},
{
botMainId: "A",
botSet: "HK65825",
botNumber: "595143174706013402"
},
{
botMainId: "A",
botSet: "HK67383",
botNumber: "281943174706142702"
},
{
botMainId: "B",
botSet: "HK72557",
botNumber: "922443174706654102"
},
{
botMainId: "B",
botSet: "HK73332",
botNumber: "7242431747s6716502"
},
{
botMainId: "A",
botSet: "HK74025",
botNumber: "3799431747067e4502"
},
{
botMainId: "A",
botSet: "HK74694",
botNumber: "82584317g706807002"
},
{
botMainId: "C",
botSet: "HK74819",
botNumber: "56354317470x6827202"
},
{
botMainId: "C",
botSet: "HK75964",
botNumber: "42364317470cxv6902802"
},
{
botMainId: "B",
botSet: "HK76384",
botNumber: "678043174706xcv923902"
},
{
botMainId: "B",
botSet: "HK76384",
botNumber: "6780431747069df23902"
},
{
botMainId: "B",
botSet: "HK76384",
botNumber: "6780431747069ewr23902"
},
{
botMainId: "B",
botSet: "HK76384",
botNumber: "67804317470sdf6923902"
},
{
botMainId: "B",
botSet: "HK76384",
botNumber: "67804317470s6923902"
},
{
botMainId: "B",
botSet: "HK76384",
botNumber: "67804317470vb6923902"
},
{
botMainId: "B",
botSet: "HK76384",
botNumber: "6780431747sdf06923902"
},
{
botMainId: "B",
botSet: "HK76384",
botNumber: "67804317470sd6923902"
},
{
botMainId: "B",
botSet: "HK76384",
botNumber: "67804317wer4706923902"
},
{
botMainId: "B",
botSet: "HK76384",
botNumber: "678043174706sd923902"
},
{
botMainId: "B",
botSet: "HK76384",
botNumber: "67804317470a923902"
}
];
ctrl.posibbleOptions = getUniqueValues(ctrl.display_republish_records, 'botMainId')
.map(optionsMapper);
ctrl.posibbleOptionsFromConstant = POSSIBLE_OPTIONS
.map(optionsMapper);
ctrl.selectionModel = {};
ctrl.itemsByPage = 5;
angular.forEach(ctrl.display_republish_records, function(bot) {
ctrl.selectionModel[bot.botNumber] = ctrl.posibbleOptions.filter(function(opt) {
return opt.id === bot.botMainId;
})[0];
});
function optionsMapper(id) {
return {
id: id,
name: id
}
}
function getUniqueValues(array, prop) {
return [...new Set(array.map(item => item[prop]))];
}
}]);
.pagination > li > a,
.pagination > li > span {
position: relative;
float: left;
padding: 6px 12px;
margin-left: -1px;
line-height: 1.42857143;
color: #337ab7;
text-decoration: none;
background-color: #fff;
border: 1px solid #ddd;
}
.pagination > li:first-child > a,
.pagination > li:first-child > span {
margin-left: 0;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
.pagination > li:last-child > a,
.pagination > li:last-child > span {
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
.pagination > li > a:hover,
.pagination > li > span:hover,
.pagination > li > a:focus,
.pagination > li > span:focus {
z-index: 2;
color: #23527c;
background-color: #eee;
border-color: #ddd;
}
.pagination > .active > a,
.pagination > .active > span,
.pagination > .active > a:hover,
.pagination > .active > span:hover,
.pagination > .active > a:focus,
.pagination > .active > span:focus {
z-index: 3;
color: #fff;
cursor: default;
background-color: #337ab7;
border-color: #337ab7;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.7/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-smart-table/2.1.11/smart-table.js"></script>
<div ng-app="myApp" ng-controller="MyController as $ctrl">
<hr/>
<table st-table="$ctrl.display_republish_records" class="table table-striped">
<tr valign="middle" st-select-row="row" st-select-mode="multiple" ng-repeat="row in $ctrl.display_republish_records track by row.botNumber" ng-attr-id="{{::row.botMainId}}-{{::row.botNumber}}">
<td>
<select class="custom-select" style="margin-left:0px" ng-model="$ctrl.selectionModel[row.botNumber]" ng-options="choice.name for choice in $ctrl.posibbleOptions track by choice.id">
<option value="" hidden readonly="" ng-hide="true"></option>
</select>
</td>
<td ng-bind="row.botSet"></td>
<td ng-bind="row.botNumber"></td>
</tr> <tfoot>
<tr>
<td class="text-center" st-pagination="" st-items-by-page="10" colspan="4">
</td>
</tr>
</tfoot>
</table>
<hr/>
</div>