Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
====================================Service Code==============================================================
app.factory('LiveDataService' , function($http,$rootScope){
return {
getAdminLiveData : function(){
var alivedata = $http.get('/gotekt/livedata/alldata');
return alivedata;
},
getUserLiveData : function(){
var uid = $rootScope.user.id;
var ulivedata = $http.get('/gotekt/livedata/userdata/'+uid);
return ulivedata;
}
};
});
===================================Controller Code============================================================
app.controller('AdminLiveDataController', AdminLiveDataController);
function AdminLiveDataController($scope,LiveDataService){
LiveDataService.getAdminLiveData().then(function(response){
$scope.adatas = response.data;
});
}
=====================================View code=================================================================
<div class="panel panel-default">
<div class="panel-heading">All Live Data</div>
<div class="table-responsive">
<table class="table table-striped b-t b-b">
<thead>
<tr>
<th style="width:5%" class="text-center">No.</th>
<th style="width:20%" class="text-center">Object Name</th>
<th style="width:20%" class="text-center">Object UUID</th>
<th style="width:15%" class="text-center">Object Type</th>
<th style="width:10%" class="text-center">Object Room</th>
<th style="width:15%" class="text-center">Object Floor</th>
<th style="width:15%" class="text-center">Timestamp</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="adata in adatas">
<td style="width:5%" class="text-center">
{{ $index+1 }}
</td>
<td style="width:20%" class="text-center">
{{ adata.object_name }}
</td>
<td style="width:20%" class="text-center">
{{ adata.uuid }}
</td>
<td style="width:15%" class="text-center">
{{ adata.object_type }}
</td>
<td style="width:10%" class="text-center">
{{ adata.receiver_location }}
</td>
<td style="width:15%" class="text-center">
{{ adata.receiver_floor }}
</td>
<td style="width:15%" class="text-center">
{{ adata.created_at}}
</td>
</tr>
</tbody>
</table>
</div>
</div>
=================================================================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.