为什么价值是“;未定义的“;在传递到控制器功能之后
Why value is "Undefined" after passing to controller function
我不确定console.log
为什么说未定义
$scope.onSizeSelected = function(productId, sizeQtyPrice){
console.log('size selected ...' + sizeQtyPrice);
$scope.updateSelectedProductBySizeSelected(productId ,sizeQtyPrice);
};
我的html div
标签:
<div ng-show="product[0].sizeQtyPrice[0].size > 0" ng-init="onSizeSelected(product[0].id, product[0].sizeQtyPrice[0])" >Select a Size</div>
我的http
内部控制器:
$http.get("/get_product_details/?prod_id=1")
.success(function (response) {
$scope.product = response;
}).error(function(){
console.log('Error happened ... ');
});
product
低于response
:
[
{
"selectedQtyOptions": [],
"selectedSize": "",
"description": "taxiing",
"selectedQty": "1",
"title": "nationally",
"brand": "Brand2",
"product_identifier_type": "SKU",
"images": [
{
"image0": "/media/products/bb61e8ae422b736ff6c1b9562cbde883.jpg"
}
],
"sizeQtyPrice": [
{
"discountAttributes": "Jung fords redskin richest pearl paperweight careen confides backstage gushing",
"measureUnit": "mm",
"discountPercent": 5,
"mrp": 8269,
"qty": 2,
"size": 62
},
{
"discountAttributes": "snitched wisps unambiguously harshest clothed famished spec triathlon Ethelred addicts",
"measureUnit": "Kg",
"discountPercent": 10,
"mrp": 5644,
"qty": 6,
"size": 92
},
{
"discountAttributes": "committal forming Welsh mawkishly swapped merchandize brawn demises emailed UCLA",
"measureUnit": "Kg",
"discountPercent": 3,
"mrp": 7106,
"qty": 5,
"size": 32
}
],
"product_identifier": "8e4e9389-6c46-4dc8-8716-0c7d2e580d3e",
"id": 1
}
]
原因是:在ajax返回之前调用onSizeSelected
。
$http.get("/get_product_details/?prod_id=1")
.success(function (response) {
$scope.product = response;
//<------------ set here the data
}).error(function(){
console.log('Error happened ... ');
});
相关文章:
- 在指令控制器中使用$attrs时出现问题
- electronic BrowserWindow的最小高度和宽度在hide()show()方法之后不起作用
- 有没有任何方法可以将控制器从文件加载到ui路由器$stateProvider中
- 在chrome.tabs.onCreated之后加载HTML页面
- 在将绑定应用于控制器之后,是否会发出Angular$scope事件
- 如何确保Rails资产管道中的JQuery脚本在控制器特定的JS之后被调用
- 在调用AJAX之后显示ng控制器的内容;作为“;作用
- 在$state.go之后在控制器之间传递数据
- $stateParams变为'未定义'在传递到控制器之后
- 在 ng 选项之后完成控制器内部的回调函数
- 即使在函数中将returnValue设置为False之后,控制器动作仍在执行
- 指令中ngChange事件之后的控制器函数
- 为什么价值是“;未定义的“;在传递到控制器功能之后
- 在执行服务之后延迟控制器初始化
- $http之后更新多个控制器中的作用域
- Angular.js控制器在视图加载之后加载
- 在Angular JS中,如何在动画之后触发控制器函数
- 控制器中的Angular函数在承诺之后没有被调用
- 在控制器中的所有异步执行之后调用“渲染”的正确方法是什么
- 在控制器将数据发送到jsp之后,如何启动脚本