I am new in Angular JS and learning it. I have a div and i want load data on startup with controller but i want reload it again when data has a new record.
index.html
<div id="third-content" ng-controller="IndexCtrl">
<table id="table-class-detail" class="table table-atd table-responsive" ng-init="reloadElement('page001')">
<tbody><tr><td>Loading...</td></tr></tbody>
</table>
</div>
Angularjs Module :
var app = angular.module('app',['ngRoute','controller'])
.config(function($routeProvider){
$routeProvider
.when('/home',{
controller: 'AtdCtrl'
})
.otherwise({
//templateUrl: 'temp/404.html'
})
})
controller :
angular.module('controller',[])
.controller('IndexCtrl', ['$scope', '$http', '$log', function($scope, $http, $log) {
$scope.getCurrentClass = function($params){
$interval(function(){
$http.post('./reloadpage.php',{'temp':$params})
.success(function(data){
$("#table-class-detail tbody").html("<tr><td>Name:</td><td>"+data.name+"</td></tr> <tr><td>Code:</td><td>"+data.code+"</td></tr>");
})
.error(function(error){
$log.error(error);
})
},1000);
}
}])
reloadpage.php
$data = json_decode(file_get_contents("php://input"));
$temp = $data->temp;
$records = array();
$result = $this->currentClass($temp);
if(!empty($result)){
$records = array('name' => $result->name,'code' => $result->code);
}else $records = null;
echo json_encode($records);
I follow tutorial form this site it's not working, i got an error ReferenceError: $interval is not defined
Can anyone help me ? How to reload/refresh element on table-class-detail tbody
$intervalwith it so that we can see the problem clearer.