国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術(shù)文章
文章詳情頁

javascript - angular中controller里面雙層遍歷為何實現(xiàn)不了

瀏覽:93日期:2023-03-06 13:46:34

問題描述

我需要實現(xiàn)這個功能,把獲得的數(shù)據(jù)進(jìn)行遍歷出一層,然后再對每一項遍歷,把每一項的數(shù)據(jù)的某個值賦予給上一層,但是卻實現(xiàn)不了。怎么辦?代碼: var datalist=[];

var dataDe = data.body.data.assets;for(var i = 0;i<dataDe.length;i++){ for(var j= 0;j<dataDe[i].userAssetList.length;j++){dataDe[i].userDtoName = dataDe[i].userAssetList[j];datalist.push(dataDe[i]); }}$scope.datalist=datalist; 事實證明第二個循環(huán)里面的值alert可以出來。但是賦值給外層的元素就不行了。怎么解決。求大神。 數(shù)據(jù)結(jié)構(gòu)如下:我是想把userassetlist里面的數(shù)組進(jìn)行遍歷然后賦值給上一層。'data': {'assets': [ {'id': '001','assetCount': 14,'availableCount': 9,'price': 2,'startDate': null,'age': 0,'description': '','assetType': '臺式機(jī)','assetName': '賽爾','assetModel': 'Z-01','userAssetList': [ {'userDTO': { 'confirmationDate': null, 'firstJobDate': null, 'id': '', 'userCount': 0, 'orgList': [], 'roleList': [], 'salaryTypeList': [], 'socialSecurityList': [], 'failCount': 0, 'name': '管理員', 'personalEmail': '932276768@qq.com', 'personalPhone': '', 'personalPhoneCountryCode': '86', 'lastSalary': 0, 'lastSalaryStartDate': null, 'currentSalary': 0, 'currentSalaryStartDate': null, 'birthDate': null, 'joiningDate': null, 'successCount': 0, 'locked': false, 'identified': true, 'active': false},'count': 3 }, {'userDTO': { 'confirmationDate': null, 'firstJobDate': null, 'id': '', 'userCount': 0, 'orgList': [], 'roleList': [], 'salaryTypeList': [], 'socialSecurityList': [], 'failCount': 0, 'name': '沙琪瑪', 'personalEmail': 'zdygx951@163.com', 'personalPhone': '17328121234', 'personalPhoneCountryCode': '86', 'lastSalary': 0, 'lastSalaryStartDate': null, 'currentSalary': 0, 'currentSalaryStartDate': null, 'birthDate': null, 'joiningDate': null, 'successCount': 0, 'locked': false, 'identified': true, 'active': false},'count': 2 }],

問題解答

回答1:

為什么不可以呢,你的代碼,一行沒改:

var data = { 'assets': [ {'id': '001','assetCount': 14,'availableCount': 9,'price': 2,'startDate': null,'age': 0,'description': '','assetType': '臺式機(jī)','assetName': '賽爾','assetModel': 'Z-01','userAssetList': [{ 'userDTO': {'confirmationDate': null,'firstJobDate': null,'id': '','userCount': 0,'orgList': [],'roleList': [],'salaryTypeList': [],'socialSecurityList': [],'failCount': 0,'name': '管理員','personalEmail': '932276768@qq.com','personalPhone': '','personalPhoneCountryCode': '86','lastSalary': 0,'lastSalaryStartDate': null,'currentSalary': 0,'currentSalaryStartDate': null,'birthDate': null,'joiningDate': null,'successCount': 0,'locked': false,'identified': true,'active': false }, 'count': 3},{ 'userDTO': {'confirmationDate': null,'firstJobDate': null,'id': '','userCount': 0,'orgList': [],'roleList': [],'salaryTypeList': [],'socialSecurityList': [],'failCount': 0,'name': '沙琪瑪','personalEmail': 'zdygx951@163.com','personalPhone': '17328121234','personalPhoneCountryCode': '86','lastSalary': 0,'lastSalaryStartDate': null,'currentSalary': 0,'currentSalaryStartDate': null,'birthDate': null,'joiningDate': null,'successCount': 0,'locked': false,'identified': true,'active': false }, 'count': 2}] } ]}var datalist=[];var dataDe = data.assets;for(var i = 0;i<dataDe.length;i++){ for(var j= 0;j<dataDe[i].userAssetList.length;j++){dataDe[i].userDtoName = dataDe[i].userAssetList[j];datalist.push(dataDe[i]); }}

標(biāo)簽: JavaScript
相關(guān)文章:
主站蜘蛛池模板: 五原县| 五指山市| 新乡县| 河北区| 开江县| 焉耆| 上蔡县| 连云港市| 寿宁县| 蒙城县| 平湖市| 三台县| 金湖县| 恩平市| 清水县| 乐都县| 浦城县| 健康| 绥棱县| 扎囊县| 清远市| 昭通市| 通州区| 定南县| 鲁甸县| 恭城| 南汇区| 鹤岗市| 永川市| 海盐县| 宜章县| 曲靖市| 双峰县| 小金县| 江油市| 仙游县| 绥滨县| 钟山县| 宽城| 大英县| 吴忠市|