我如何用user.firstName替换javascript user [0] .firstName

时间:2015-07-02 15:53:04

标签: javascript angularjs

您好我想从我的对象中访问这样的信息

user.firstName

但我现在正在这样做

user[0].firstName

我使用角度js

这是对象结构

0: ObjectAccessKey: "example.com"BirthDate: "1969-12-31"CellPhone: "(888) 888-8888"City: "Holtwood"ClosedRegisterAt: nullCompanyId: "1"CreatedAt: "2015-05-31 20:31:00"EditedAt: "2015-05-31 21:32:22"EmergencyContactName: "hhhehee"EmergencyContactPhone: "(717) 444 4344"Employee: "Ben Eshleden"EmployeeId: "8"FirstName: "Ben"LastName: "Eshleden"MailingAddress: "1131 holtwood rd"OpenedRegisterAt: nullPassword: "candoa21"State: "AK"ZipCode: "17532"

1 个答案:

答案 0 :(得分:1)

使用

$.each(user, function (i, eachuser) {
 name = eachuser.firstname;
}