Angularjs按需查詢實(shí)例代碼
課程信息管理界面有這樣一個需求,當(dāng)課程類型為公選課的時候,可以選擇課程性質(zhì),當(dāng)為其他課程類型的時候,不必選擇課程性質(zhì)。
代碼:
/**
* 獲取課程類型下拉框數(shù)據(jù)
*/
getCourseTypeNameOptions(){
let url = "teachingManagement-web/course/queryAllCourseType";
this.http.get(url).subscribe(
res =>{
this.courseTypeNameOptions = res.json().data;
//如果是公共選修,可以選擇課程性質(zhì),如果不是,課程性質(zhì)為空
this.courseTypeNameOptions.forEach(item =>{
JSON.stringify(item);
console.log(item);
if(item.dictionaryName == "公共選修課"){
this.getCourseNatureNameOptions();
}else{
return;
}
})
}
);
}
/**
* 課程類型為公共選修課,可選擇課程性質(zhì);其他類型,則不需選擇課程性質(zhì)
* @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");
}
}
總結(jié)
以上所述是小編給大家介紹的Angularjs按需查詢實(shí)例代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
相關(guān)文章
詳解Angular組件數(shù)據(jù)不能實(shí)時更新到視圖上的問題
解決angular 使用原生拖拽頁面卡頓及表單控件輸入延遲問題
Angular angular-file-upload文件上傳的示例代碼
在angularJs中進(jìn)行數(shù)據(jù)遍歷的2種方法
Angular HMR(熱模塊替換)功能實(shí)現(xiàn)方法
使用AngularJS編寫多選按鈕選中時觸發(fā)指定方法的指令代碼詳解
Angular項(xiàng)目如何升級至Angular6步驟全紀(jì)錄
Angular.js實(shí)現(xiàn)掃碼槍掃碼并生成二維碼

