1
這是我的angularjs代碼和我得到的控制檯響應,但無法顯示它來顯示它..我越來越從功能響應,但無法與angularjs
{{user.email}}
var app = angular.module('myApp', []);
app.controller('apppCtrl', function($scope,$http) {
$scope.displayProfile=function(){
$http.get("../api/user_data.php")
.then(function(data){
$scope.user=data
})
// alert("Angularjs call function on page load");
}
});
輸出
{"data":[{"id":"10","name":"Imran","last_name":"","email":"[email protected]",
"password":"pass","city":"","address":"[email protected]","gender":"","dob":"","img":""}],
"status":200,
"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],
"jsonpCallbackParam":"callback",
"url":"../api/user_data.php",
"headers":{"Accept":"application/json, text/plain, */*"}},"statusText":"OK"}
從在響應中的對象的數據屬性是一個陣列,指針添加到元件實際顯示在視圖中的數據 – nosthertus
@nosthertus是的,你是對的,我不知道,因爲在我寫答案的時候,OP沒有提到響應數據。我現在已經更新了答案。 – Gaurav
感謝它現在正在工作 –