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
感谢它现在正在工作 –