課程信息管理界面有這樣一個需求,當課程類型為公選課的時候,可以選擇課程性質,當為其他課程類型的時候,不必選擇課程性質。
代碼:
/** * 獲取課程類型下拉框數據 */ 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"); } }
總結
以上所述是小編給大家介紹的Angularjs按需查詢實例代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對武林網網站的支持!
新聞熱點
疑難解答