ng- repeat显示的行等于no属性,甚至不显示html视图上的数据
html:
<div ng-repeat="addr in addrShipData">
<input type="radio" name="resp1" ng-checked='true'/>
{{addr.addressLine1 +","+addr.addressLine2+", "+addr.city+ ","+addr.state+", "+addr.country+", "+addr.zipCode+","+addr.contactNum}}
<a>Edit</a>
</div>
js code:
var dataObj = [];
var shipDataObj = [];
//var addrShipData =[];
function shipData(shipDataObj){
for(i=0;i<shipDataObj.length;i++){
dataObj.push(addressLine1 = shipDataObj[i].addressLine1);
dataObj.push(addressLine2 = shipDataObj[i].addressLine2);
dataObj.push(city = shipDataObj[i].city);
dataObj.push(state = shipDataObj[i].state);
dataObj.push(country = shipDataObj[i].country);
dataObj.push(zip = shipDataObj[i].zipCode);
dataObj.push(contactNum = shipDataObj[i].contactNumber);
}
}
appServices.getAddress(userData.customerId).then(function (data){
if (data){
console.log(data);
$scope.shipDataObj = data;
shipData(data);
console.log("dataObj properties: " + dataObj);
$scope.addrShipData = dataObj;
console.log($scope.addrShipData);
if ($scope.addrShipData){
storeLocally.set('shipInfo :', $scope.addrShipData);
}
else{
$scope.addressError = "No Address Found!";
}
console.log("address info:- " + $scope.addrShipData);
}
}),
function (data) {
if (data.status == 500) {
$scope.addressError = "Oops! No Address Found!";
};
}
In js file I debug the code I am getting all values in $scope.addrShipdata in HTML view I am not getting any value.
在js文件中我调试代码我在HTML视图中获取$ scope.addrShipdata中的所有值我没有得到任何值。
i am getting o/p like this
我得到这样的o / p
on console: 1234 waller ave,suite1,fremont,California,USA,246326,213-435-4365
在控制台上:1234 waller ave,suite1,fremont,California,USA,246326,213-435-4365
on html view: it is displaying blank. O ,, , , , , Edit O ,, , , , , Edit O ,, , , , , Edit O ,, , , , , Edit O ,, , , , , Edit O ,, , , , , Edit O ,, , , , , Edit
在html视图上:它显示为空白。 O ,,,,,编辑O ,,,,,编辑O ,,,,,编辑O ,,,,,编辑O ,,,,,编辑O ,,,,,编辑O, ,,,,,编辑
I am not getting any error either.I don't understand where is problem in code.
我也没有收到任何错误。我不明白代码中的问题在哪里。
1 个解决方案
#1
0
You haven't created correct object definition which you are expecting in ng-repeat
tempalte. Also you should create a whole object and push it to dataObj
which will basically add object with new properties.
您还没有在ng-repeat tempalte中创建正确的对象定义。此外,您应该创建一个完整的对象并将其推送到dataObj,这将基本上添加具有新属性的对象。
Code
for (i = 0; i < shipDataObj.length; i++) {
dataObj.push({
addressLine1: shipDataObj[i].addressLine1,
addressLine2: shipDataObj[i].addressLine2,
city: shipDataObj[i].city,
state: shipDataObj[i].state,
country: shipDataObj[i].country,
zip: shipDataObj[i].zipCode,
contactNum: shipDataObj[i].contactNumber
});
}
更多相关文章
- 如何将对象作为参数传播给函数?
- RangeError:在Node.js中调试/记录/检查对象时超过了最大调用堆栈
- 是否有一个简单的库将JSON对象渲染为树?
- 在JavaScript中进行文件处理,第四部分:对象URLs
- 我在显示随机选择的对象时遇到问题
- 如何在JavaScript / jQuery中获取对象的属性?
- 【JavaScript】JavaScript的对象-对象专门语句
- 令人惊奇的JavaScript面向对象(一)
- JavaScript面向对象程序设计三——原型模式(上)