javascript
angularJS求助
找大佬求解angular,下面兩個加粗的方法,執(zhí)行結(jié)果是:外層遍歷完畢,才依次執(zhí)行另一個方法,并且后執(zhí)行的方法中,對顏色的修改代碼不生效,在外層方法里,內(nèi)層方法外修改顏色代碼是生效的,如何讓代碼生效或者順序執(zhí)行?(省略部分無關(guān)代碼)
 getDevListCom(): void {
 this.DevStatusdata = [];
 this.devMonitorService.getDevList(this.reqdevlistdata)
 .subscribe(_data => {
 this.DevStatusdata = _data.data.monitorInfo.devMonitorGroups[0].devList;
 this.Ex_totalCount = _data.data.monitorInfo.devMonitorGroups[0].totalCount;
 this.Ex_serviceCount = _data.data.monitorInfo.devMonitorGroups[0].serviceCount;
 this.Ex_unserviceCount = _data.data.monitorInfo.devMonitorGroups[0].totalCount -
 _data.data.monitorInfo.devMonitorGroups[0].serviceCount;
 this.page.totalRow = _data.page.totalPage;
 this.loading = false;
 this.DevStatusdata.forEach(data1 => {
 if (data1.devRunStatus == ‘正常’) {
 data1.color = ‘dodgerblue’;
 } else if (data1.devRunStatus == ‘部分服務(wù)’) {
 data1.color = ‘#dd3b26’;
 } else {
 data1.color = ‘gray’;
 }
 });
 //console.log(this.DevStatusdata);
 this.runimg_Array = [];
 this.DevStatusdata.forEach(data1 => {
 if (data1.devRunStatus === ‘正常’) {
 this.runimg_Array.push(‘a(chǎn)ssets/images/operate/allnormal.png’);
 } else if (data1.devRunStatus === ‘停止服務(wù)’) {
 this.runimg_Array.push(‘a(chǎn)ssets/images/operate/stopservice.png’);
 } else if (data1.devRunStatus === ‘部分服務(wù)’) {
 this.runimg_Array.push(‘a(chǎn)ssets/images/operate/Partynormal.png’);
 } else if (data1.devRunStatus === ‘P通訊故障’) {
 this.runimg_Array.push(‘a(chǎn)ssets/images/operate/communicationfail.png’);
 } else if (data1.devRunStatus === ‘維護(hù)’) {
 this.runimg_Array.push(‘a(chǎn)ssets/images/operate/maintain.png’);
 } else if (data1.devRunStatus === ‘關(guān)機(jī)’) {
 this.runimg_Array.push(‘a(chǎn)ssets/images/operate/shutdown.png’);
 } else if (data1.devRunStatus === ‘停用’) {
 this.runimg_Array.push(‘a(chǎn)ssets/images/operate/outofservice.png’);
 } else if (data1.devRunStatus === ‘疑似死機(jī)’) {
 this.runimg_Array.push(‘a(chǎn)ssets/images/operate/crash.png’);
 } else {
 this.runimg_Array.push(‘a(chǎn)ssets/images/operate/unknownstatus.png’);
 }
 });
 this.modimg_Array = [];
 this.DevStatusdata.forEach(data1 => {
 if (data1.devModStatus === ‘正常’) {
 this.modimg_Array.push(‘a(chǎn)ssets/images/operate/modnormal.png’);
 } else if (data1.devModStatus === ‘故障’) {
 this.modimg_Array.push(‘a(chǎn)ssets/images/operate/modfault.png’);
 } else if (data1.devModStatus === ‘警告’) {
 this.modimg_Array.push(‘a(chǎn)ssets/images/operate/modwarning.png’);
 } else {
 this.modimg_Array.push(‘a(chǎn)ssets/images/operate/modunknown.png’);
 }
 });
 this.cashimg_Array = [];
 this.DevStatusdata.forEach(data1 => {
 if (data1.devCashStatus === ‘正常’) {
 this.cashimg_Array.push(‘a(chǎn)ssets/images/operate/cashnormal.png’);
 } else if (data1.devCashStatus === ‘缺鈔’) {
 this.cashimg_Array.push(‘a(chǎn)ssets/images/operate/lackofcash.png’);
 } else if (data1.devCashStatus === ‘滿鈔’) {
 this.cashimg_Array.push(‘a(chǎn)ssets/images/operate/fullofcash.png’);
 } else if (data1.devCashStatus === ‘不足’) {
 this.cashimg_Array.push(‘a(chǎn)ssets/images/operate/nullofcash.png’);
 } else {
 this.cashimg_Array.push(‘a(chǎn)ssets/images/operate/unknownofcash.png’);
 }
 });
 this.cardimg_Array = [];this.DevStatusdata.forEach(data1 => {
 if (data1.devCardStatus === ‘正常’) {
 this.cardimg_Array.push(‘a(chǎn)ssets/images/operate/cardok.png’);
 } else if (data1.devCardStatus === ‘卡少’) {
 this.cardimg_Array.push(‘a(chǎn)ssets/images/operate/cardlow.png’);
 } else if (data1.devCardStatus === ‘卡空’) {
 this.cardimg_Array.push(‘a(chǎn)ssets/images/operate/cardempty.png’);
 } else {
 this.cardimg_Array.push(‘a(chǎn)ssets/images/operate/cardunknown.png’);
 }
 });
 this.netimg_Array = [];
 this.DevStatusdata.forEach(data1 => {
 if (data1.devNetStatus === ‘正常’) {
 this.netimg_Array.push(‘a(chǎn)ssets/images/operate/normalnetwork.png’);
 } else if (data1.devNetStatus === ‘故障’) {
 this.netimg_Array.push(‘a(chǎn)ssets/images/operate/networkfailure.png’);
 data1.color = ‘red’; // 添加內(nèi)容******************************************************* //
 } else {
 this.netimg_Array.push(‘a(chǎn)ssets/images/operate/unknownnetwork.png’);
 }
 });
 this.infoList4matrix = [];
 const j = parseInt(this.Ex_totalCount, 10);
 //console.log(this.DevStatusdata);
 for (let i = 0; i < j; i++) {
 if (this.DevStatusdata[i] != undefined) {
 const params = {
 devNo: this.DevStatusdata[i].no,
 };
 //console.log(params);
 //console.log(this.DevStatusdata);
 this.DevStatusdata.forEach(data1 => {
 console.log(data1.no)
 let f1 = 0;
 if(data1.no == this.DevStatusdata[i].no){
 console.log(“進(jìn)入了該方法”)
 this.devMonitorService.getDevStatus(params).subscribe(_data =>{
 const tmpList = [];
 if (_data) {
 const temp = _data.data.devStatusInfo.idcCaptureBinCount;
 if ( temp == null || temp == ‘’) {
 this.idcCaptureBinCount = ‘0’;
 } else {
 this.idcCaptureBinCount = temp;
 }
 let tmp = _data.data.devStatusInfo.idcDeviceStatus;
 if (tmp && tmp != ‘’ && tmp != ‘NO’) {
 tmpList.push({status: tmp, name: this.devMonitorService.convert(‘idc’)});
 }
 tmp = _data.data.devStatusInfo.pinDeviceStatus;
 if (tmp && tmp != ‘’ && tmp != ‘NO’) {
 tmpList.push({status: tmp, name: this.devMonitorService.convert(‘pin’)});
 }
 tmp = _data.data.devStatusInfo.siuDeviceStatus;
 if (tmp && tmp != ‘’ && tmp != ‘NO’) {
 tmpList.push({status: tmp, name: this.devMonitorService.convert(‘siu’)});
 }
 tmp = _data.data.devStatusInfo.cimDeviceStatus;
 if (tmp && tmp != ‘’ && tmp != ‘NO’) {
 tmpList.push({status: tmp, name: this.devMonitorService.convert(‘cim’)});
 }
 tmp = _data.data.devStatusInfo.cdmDeviceStatus;
 if (tmp && tmp != ‘’ && tmp != ‘NO’) {
 tmpList.push({status: tmp, name: this.devMonitorService.convert(‘cdm’)});
 }
 tmp = _data.data.devStatusInfo.crdDeviceStatus;
 if (tmp && tmp != ‘’ && tmp != ‘NO’) {
 tmpList.push({status: tmp, name: this.devMonitorService.convert(‘crd’)});
 }
 tmp = _data.data.devStatusInfo.rprDeviceStatus;
 if (tmp && tmp != ‘’ && tmp != ‘NO’) {
 tmpList.push({status: tmp, name: this.devMonitorService.convert(‘rpr’)});
 }
 tmp = _data.data.devStatusInfo.jprDeviceStatus;
 if (tmp && tmp != ‘’ && tmp != ‘NO’) {
 tmpList.push({status: tmp, name: this.devMonitorService.convert(‘jpr’)});
 }
 tmp = _data.data.devStatusInfo.depDeviceStatus;
 if (tmp && tmp != ‘’ && tmp != ‘NO’) {
 tmpList.push({status: tmp, name: this.devMonitorService.convert(‘dep’)});
 }
 tmp = _data.data.devStatusInfo.pbkDeviceStatus;
 if (tmp && tmp != ‘’ && tmp != ‘NO’) {
 tmpList.push({status: tmp, name: this.devMonitorService.convert(‘pbk’)});
 }
 tmp = _data.data.devStatusInfo.ircDeviceStatus;
 if (tmp && tmp != ‘’ && tmp != ‘NO’) {
 tmpList.push({status: tmp, name: this.devMonitorService.convert(‘irc’)});
 }
 tmp = _data.data.devStatusInfo.sprDeviceStatus;
 if (tmp && tmp != ‘’ && tmp != ‘NO’) {
 tmpList.push({status: tmp, name: this.devMonitorService.convert(‘spr’)});
 }
 tmp = _data.data.devStatusInfo.fpiDeviceStatus;
 if (tmp && tmp != ‘’ && tmp != ‘NO’) {
 tmpList.push({status: tmp, name: this.devMonitorService.convert(‘fpi’)});
 }
 tmp = _data.data.devStatusInfo.iccDeviceStatus;
 if (tmp && tmp != ‘’ && tmp != ‘NO’) {
 tmpList.push({status: tmp, name: this.devMonitorService.convert(‘icc’)});
 }
 tmp = _data.data.devStatusInfo.camDeviceStatus;
 if (tmp && tmp != ‘’ && tmp != ‘NO’) {
 tmpList.push({status: tmp, name: this.devMonitorService.convert(‘cam’)});
 }
 tmp = _data.data.devStatusInfo.dprDeviceStatus;
 if (tmp && tmp != ‘’ && tmp != ‘NO’) {
 tmpList.push({status: tmp, name: this.devMonitorService.convert(‘dpr’)});
 }
 tmp = _data.data.devStatusInfo.upsDeviceStatus;
 if (tmp && tmp != ‘’ && tmp != ‘NO’) {
 tmpList.push({status: tmp, name: this.devMonitorService.convert(‘ups’)});
 }
 tmp = _data.data.devStatusInfo.chkDeviceStatus;
 if (tmp && tmp != ‘’ && tmp != ‘NO’) {
 tmpList.push({status: tmp, name: this.devMonitorService.convert(‘chk’)});
 }
 tmp = _data.data.devStatusInfo.ttuDeviceStatus;
 if (tmp && tmp != ‘’ && tmp != ‘NO’) {
 tmpList.push({status: tmp, name: this.devMonitorService.convert(‘ttu’)});
 }
 tmp = _data.data.devStatusInfo.bcrDeviceStatus;
 if (tmp && tmp != ‘’ && tmp != ‘NO’) {
 tmpList.push({status: tmp, name: this.devMonitorService.convert(‘bcr’)});
 }
 tmp = _data.data.devStatusInfo.iscDeviceStatus;
 if (tmp && tmp != ‘’ && tmp != ‘NO’) {
 tmpList.push({status: tmp, name: this.devMonitorService.convert(‘isc’)});
 }
 }
 if (tmpList.length > 0){
 for (let i = 0;i < tmpList.length ; i++){
 if (‘密碼鍵盤模塊’ === tmpList[i].name && ‘故障’ === tmpList[i].status){
 data1.color = ‘red’;
 console.log(“1”);
 }
 if (‘存款模塊’ === tmpList[i].name && ‘故障’ === tmpList[i].status) {
 data1.color = ‘red’;
 console.log(“2”);
 }
 if (‘取款模塊’ === tmpList[i].name && ‘故障’ === tmpList[i].status) {
 f1 = 1;
 //data1.color = ‘red’;
 console.log(“3”);
 }
 if (‘讀卡器模塊’ === tmpList[i].name && ‘故障’ === tmpList[i].status) {
 data1.color = ‘red’;
 console.log(“4”);
 }
 if (‘憑條打印機(jī)模塊’ === tmpList[i].name && ‘故障’ === tmpList[i].status) {
 data1.color = ‘yellow’;
 console.log(“5”);
 }
 }
 }
 console.log(f1+"###")
 });
 }
 });
 }
 }
 }, (error) => {
 if (error instanceof HttpResponse) {
 this.message.error(error.body.retMsg);
 }
 });
 }
總結(jié)
以上是生活随笔為你收集整理的angularJS求助的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
                            
                        - 上一篇: 数字化园区建设
 - 下一篇: 重磅!骂了 10 年,微信这功能终于要来