我試圖創建使用angularJS
數據庫的連接。我使用$http.get
用於與PHP服務器
控制器
var oke = angular.module('secondApp',[]);
oke.controller('dataAdmin',function(){
return{
controller : function($scope,$http){
$scope.displayData = function(){
$http.get('db.php').success(function(hasil){
$scope.datas=hasil;
});
console.log($scope.datas);
}
}
};
});
HTML
<div ng-controller="dataAdmin" ng-init="displayData()" ng-app="secondApp">
<input type="text" ng-model="hasil" placeholder="Search" style="margin-left:2%;margin-bottom:5px;"/>
<ul>
<li ng-repeat="nt in datas | filter:hasil | orderBy:'username'">
Username : {{nt.username}} | Password : {{nt.password}}
</li>
</ul>
</div>
你這是在控制檯中得到些什麼? –