作者:舞倾城2010_217 | 来源:互联网 | 2023-06-28 14:05
Here is backend function
这是后端功能
userDetail : function(req,res){
User.findOne().where({id : req.userID}).exec(
function findOneCB(err, result) {
if (err) {
sails.log.error("Error Occurred : "+ err);
}
if(result != undefined ){
Account.find().where({userID: req.userID},{StatusCode :"Successful"}).exec(
function findCB(err, accounts) {
if (err) {
sails.log.error("Error Occurred : "+ err);
}
if(accounts != undefined ){
var sendData={
userData:result,
accountData :accounts
};
console.log(sendData);
res.json(sendData);
}
});
}
});
}
Here is frontend resource function
这是前端资源功能
(function (){
"use strict";
angular.module('userAccounts').factory('userAccountsResource',[
"$resource","$http",userAccountsResource]);
function userAccountsResource($resource,$http){
return {
getApprovedAccounts:function(){
return $resource('api/account/approvedBankAccounts');
},
getUserDetail : function(){
return $http.get('api/user/userDetail');
}
}
}
})();
resource function call on controller
资源函数调用控制器
vm.userDetail= userAccountsResource.getUserDetail();
backend send response data is
后端发送响应数据是
{ userData:
{ email: 'thusitha@gmail.com',
userName: 'thusithz',
userRole: 'Standard',
selectedAccountList:
[ { accountName: 'HSBC name',
CFIXID: 'HSBC_CFIXID',
id: '563c4d7e802127d51b3d80c7',
StatusCode: 'Pending' },
{ accountName: 'NSB plus',
CFIXID: 'NSB_CFIXID',
id: '563c4de1802127d51b3d80c8',
StatusCode: 'Pending' } ],
createdAt: '2015-11-06T05:10:18.690Z',
updatedAt: '2015-11-06T05:52:24.820Z',
verifyCode: '1446786618698FfL2_gHGexhOb_JQ',
pincode: '1111',
id: '563c363aa45b2d841afc63ab' },
accountData:
[ { TimeStamp: '1446797352',
TransactionID: 'LGPS201511613253518097',
SecretTransactionKey: 'HSBC_CFIXID03636867',
ReplyID: '35753',
StatusCode: 'Successful',
StatusDescription: 'Authentication Failed',
Tags: '',
ReturnURL: '',
userID: '563c363aa45b2d841afc63ab',
accountName: 'HSBC plus',
CFIXID: 'HSBC_CFIXID',
VerificationCode: 'LGPS3309914431991402',
createdAt: '2015-11-06T07:55:35.229Z',
updatedAt: '2015-11-06T07:55:35.229Z',
id: '563c5cf7463ef3eb0aeaf57a' } ] }
but {{vm.userDetail}} did n't show any thing
it shown {{}}
它显示{{}}
why is that..? function is properly link to the back end function and it return correct response but why is that it shown {{}} like that
这是为什么..?函数正确链接到后端函数,它返回正确的响应,但为什么它显示{{}}这样
1 个解决方案