Javascript 获取数组的单个属性
我尝试了很多方法,但我不知道如何获取数组的单个属性 我想做这个 阵列1: 然后我只想得到从数组1到数组的名称,但如何Javascript 获取数组的单个属性,javascript,arrays,angularjs,variables,Javascript,Arrays,Angularjs,Variables,我尝试了很多方法,但我不知道如何获取数组的单个属性 我想做这个 阵列1: 然后我只想得到从数组1到数组的名称,但如何 this.array2 = [{'misko'},{'misko'}]; 我的代码 this.getList = function() { this.timesheets = Timesheets.query({ projectId: $scope.selected.project[0],
this.array2 = [{'misko'},{'misko'}];
我的代码
this.getList = function() {
this.timesheets = Timesheets.query({
projectId: $scope.selected.project[0],
startWeek: this.weekStart,
endWeek: this.weekEnd
});
$log.log('1');
this.timesheetsId = this.timesheets.map(function (el) {
return { name: el._id };
$log.log('2');
});
};
我可以在控制台中看到日志1,而不是您可以使用的日志2,如下所示
this.array1 = [{name: 'misko', gender: 'male'},{name: 'misko', gender: 'male'}];
this.array2 = this.array1.map(function (el) {
return { name: el.name };
})
你可以这样用
this.array1 = [{name: 'misko', gender: 'male'},{name: 'misko', gender: 'male'}];
this.array2 = this.array1.map(function (el) {
return { name: el.name };
})
你可以这样用
this.array1 = [{name: 'misko', gender: 'male'},{name: 'misko', gender: 'male'}];
this.array2 = this.array1.map(function (el) {
return { name: el.name };
})
你可以这样用
this.array1 = [{name: 'misko', gender: 'male'},{name: 'misko', gender: 'male'}];
this.array2 = this.array1.map(function (el) {
return { name: el.name };
})
@Stweet是Timesheets.query异步函数,你需要把你的代码成功回调arhh现在我明白了,太棒了!谢谢mate@Stweet是Timesheets.query异步函数,你需要把你的代码成功回调arhh现在我明白了,太棒了!谢谢mate@Stweet是Timesheets.query异步函数,你需要把你的代码成功回调arhh现在我明白了,太棒了!谢谢mate@Stweet是Timesheets.query异步函数,你需要把你的代码成功回调arhh现在我明白了,太棒了!四氢呋喃