Angularjs按需查询

来源:互联网 发布:java跨域上传文件 编辑:程序博客网 时间:2024/05/29 07:26

课程信息管理界面有这样一个需求,当课程类型为公选课的时候,可以选择课程性质,当为其他课程类型的时候,不必选择课程性质。
这里写图片描述
这里写图片描述
代码:

/** * 获取课程类型下拉框数据 */  getCourseTypeNameOptions(){      let url = "teachingManagement-web/course/queryAllCourseType";      this.http.get(url).subscribe(          res =>{              this.courseTypeNameOptions = res.json().data;              //如果是公共选修,可以选择课程性质,如果不是,课程性质为空              this.courseTypeNameOptions.forEach(item =>{                JSON.stringify(item);                console.log(item);                if(item.dictionaryName == "公共选修课"){                  this.getCourseNatureNameOptions();                }else{                  return;                }              })          }      );  }  /**   * 课程类型为公共选修课,可选择课程性质;其他类型,则不需选择课程性质   * @param type    */  changeType(type:string){    let dictionaryName=this.courseTypeNameOptions.find(x=>x.id==type).dictionaryName;//获取的课程类型名称    this.dictionaryName=dictionaryName;      if(this.dictionaryName=="公共选修课"){      this.renderer2.removeAttribute(this.courseNature.nativeElement,"disabled");    }else{        this.courseInfo.courseNatureId="";       this.renderer2.setAttribute(this.courseNature.nativeElement,"disabled","disabled");    }  }
原创粉丝点击