加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

《Angular4之Typescript用法》

发布时间:2020-12-17 08:24:24 所属栏目:安全 来源:网络整理
导读:前言: 随着Angular的深入实践,对于typescript用法一些细节之处很值得去总结的,请随小编一起来看看吧。 正文: find this.eachName = this.allCount.find(x = x.id == Id).index; forEach this.questionTypeSetModels.forEach( sc = { this.sum = (Number)

前言:

随着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
RemoveQuestionTypeRecord(index): void {
    this.disabled.splice(index,1);
    this.isShowArray.splice(index,1);
    this.questionTypeSetModels.splice(index,1);
  }

filter

//选择班级id,根据班级id查询学生
  //ITOO-FrontEndsrcappworkspaceexam-manageexam-configureexam-configure-byhandbind-exam-studentbind-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-FrontEndsrcappworkspaceexamination-questions-managetemplate-managequestion-type-score-infocustom-settingscustom-settings.component.ts
coustomQuestion = this.questionTypeScoreInfoModels.concat(this.mustQuestionList);

结语:

点滴积累,大大提升开发效率

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读