我需要获取数组中的元素。
States =[MiN_LENGTH = 2, MIN_PWD_LENGTH = 8]
var result = this.States.map(t=> t.MIN_PWD_LENGTH);
答案 0 :(得分:1)
希望这个stackblitz可以为您提供帮助。
.ts
States = [{ MiN_LENGTH: 2, MIN_PWD_LENGTH: 8 }];
test;
ngOnInit() {
var result = this.States.map(t => t.MIN_PWD_LENGTH);
this.test = this.States.map(t => t.MIN_PWD_LENGTH);
console.log('result', result);
}