如何使用 angular 7 从对象数组中 return userPass 的值?
How to return value of userPass from array of object using angular 7?
如何使用 angular 7 从对象数组访问 userPass 的值?
我需要从对象数组
访问 属性 userPass 值
我有变量类型 any his name auth
auth 有对象数组
我需要从下面的 json 访问 属性 用户密码的值
var auth;
auth =
[{"userLoginID":0,"userName":"test","userMail":"ahmedsa.aziz.ba@gmail.com","userPass":"12345678","fkTeamID":0
,"isAdmin":false,"createdBy":0,"createdDate":"0001-01-01T00:00:00","isHidden":false}]
我需要访问 userPass 值,这意味着我需要访问 12345678
我尝试的是
ngOnInit() {
auth.forEach(element => {
element.forEach(au => {
console.log(au.userPass);
});
});
userpathvalue=???
}
意味着我需要访问值 12345678
因为你的数组长度是1,所以这段代码足以获取值。
auth[0].userPass
所以,如果你这样做:
console.log(auth[0].userPass)
它将打印"12345678"
*注意:此解决方案仅适用于您的特定情况,因为您的数组长度为一,如果多则必须循环。
如何使用 angular 7 从对象数组访问 userPass 的值?
我需要从对象数组
访问 属性 userPass 值我有变量类型 any his name auth
auth 有对象数组
我需要从下面的 json 访问 属性 用户密码的值
var auth;
auth =
[{"userLoginID":0,"userName":"test","userMail":"ahmedsa.aziz.ba@gmail.com","userPass":"12345678","fkTeamID":0
,"isAdmin":false,"createdBy":0,"createdDate":"0001-01-01T00:00:00","isHidden":false}]
我需要访问 userPass 值,这意味着我需要访问 12345678
我尝试的是
ngOnInit() {
auth.forEach(element => {
element.forEach(au => {
console.log(au.userPass);
});
});
userpathvalue=???
}
意味着我需要访问值 12345678
因为你的数组长度是1,所以这段代码足以获取值。
auth[0].userPass
所以,如果你这样做:
console.log(auth[0].userPass)
它将打印"12345678"
*注意:此解决方案仅适用于您的特定情况,因为您的数组长度为一,如果多则必须循环。