我希望能够从一个对象获取所有键。假设对象如下所示:
this.reservation = { "Firstname" : "" , "Lastname" :"" , "Phone" : "", "Email" : "", "Date" : "yyyy-mm-dd hh:mm", "Starthour" : "", "Endhour" : "", "Persons" : "" }
如果我想检查所有键的值是否都是""
,Date
当然,我该怎么做呢?
我尝试做一个forEach
来获取密钥:
angular.forEach(this.reservation, function(value, key) { console.log(key); });
但这是行不通的。有什么提示吗?
尝试这个,
Object.keys(reservation);