- 私のサービスではなく、コントローラではなくhttpを使用しますか?
- 私は、$ scopeでデータを表示しようとすると、私のconsole.logで定義されていません。
ここに私のコード
app.controller('adminControl', ['$scope','$routeParams','$route','adminService', function($scope,$routeParams,$route,adminService){
$scope.data = adminService.listOfAdmin();
console.log($scope.data);
}]).service('adminService', ['$http', function($http){
this.get = function(url){
return $http({
method:'GET',
url:url
}).then(function(response){
return response;
});
}
this.listOfAdmin = function(){
this.get('http://localhost/project/s9/ayu/admin/sys/mac.php?act=administrator')
.then(function(response){
return response.data;
});
}
}]);
iが出力を得ました。 ng-repeat broでどのように表示するのですか? –
$ scope.myArray = response.data; ng-repeat = "n in myArray" ?? – yBrodsky
はい、問題なく動作しますが、コントローラを変更しました: adminService.listOfAdmin()。(機能(応答){ $ scope.data = response.data; }); Thnks –