前言:
随着Angular的深入实践,对于typescript用法一些细节之处很值得去总结的,请随小编一起来看看吧。
正文:
find
this.eachName = this.allCount.find(x => x.id == Id).index;
forEach
this.questionTypeSetModels.forEach( sc => { this.sum = (Number)(this.sum) + (Number)(sc.questionTypescore); } )
splice
@H_403_16@
RemoveQuestionTypeRecord(index): void { this.disabled.splice(index,1); this.isShowArray.splice(index,1); this.questionTypeSetModels.splice(index,1); }
filter
//选择班级id,根据班级id查询学生 //ITOO-FrontEnd\src\app\workspace\exam-manage\exam-configure\exam-configure-byhand\bind-exam-student\bind-exam-student.component.ts selectClass(id: string,capnum:string,checked: boolean) { var index: number = this.classIds.indexOf(id); var indexCap:number=this.capacitys.indexOf(capnum) if (checked) { if (index < 0) { this.classIds.push(id); this.capacitys.push(capnum); } } else { if (index > -1) { this.classIds = this.classIds.filter((ele,index) => { return ele != id; }) this.capacitys=this.capacitys.filter((ele,indexCap) => { return ele != capnum; }) } } console.log(this.classIds) if(this.classIds.length<=0){ this.studentList=[]; } else{ //根据班级id数组查询有多少学生 this.getStudent(this.classIds) } }
concat
ITOO-FrontEnd\src\app\workspace\examination-questions-manage\template-manage\question-type-score-info\custom-settings\custom-settings.component.ts
coustomQuestion = this.questionTypescoreInfoModels.concat(this.mustQuestionList);
结语:
点滴积累,大大提升开发效率
@H_403_16@ 原文链接:https://www.f2er.com/angularjs/145017.html