我打電話從我的mysql數據庫與http.get(url)的角度信息,並最終填充表中的信息。從角度自動從MySQL重新加載表
這是行得通的,但現在我希望控制器在數據庫自動更改時調用http.get(url),而無需手動刷新頁面。
評論或建議很受歡迎:D (我有點新的角度)。
這是我當前的代碼:
data.js
angular.module('demo', [])
.controller('Hello', function($scope, $http, $timeout) {
$scope.loadData = function(){
$http.get('http://localhost:8888/nuevo/respuesta.php').
then(function(response) {
$scope.greeting = response.data;
//console.log($scope.greeting);
//console.log("hola");
});
};//se cierra la funcion
$scope.loadData();
});
的index.html
<div ng-controller="Hello">
<table>
<tr>
<th>ID</th>
<th>Banda</th>
<th>Cancion</th>
</tr>
<tr ng-repeat="x in greeting">
<td>{{x.`enter code here`IdCancion}}</td>
<td>{{x.Bandas_Musicales}}</td>
<td>{{x.Canciones}}</td>
</tr>
</table>
<button ng-click="loadData()">reload</button>
</div>
顯示一些代碼..它增加了獲得幫助的機率。 –
哦對不起,你走了。 –