我有一个n输入json就像
var err= {"errors":
{"username": ["Invalid login ID"],
"password": ["Invalid password"]
}
};
我必须使用angular.forEach获取用户名和密码的值。任何代码段吗?
答案 0 :(得分:0)
angular.forEach(err['username'], function (username) {
// here you will get all data which are part of username
console.log(username); // You will see result as "Invalid login ID"
});
angular.forEach(err['password'], function (password) {
// here you will get all data which are part of username
console.log(password); // You will see result as "Invalid password"
});