为什么传递给控制器​​函数后值是 "Undefined"

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
}
]   

原因是: onSizeSelected 在 ajax returns 之前被调用。

$http.get("/get_product_details/?prod_id=1")
        .success(function (response) {
            $scope.product = response;
             //<------------ set here the data
        }).error(function(){
            console.log('Error happened ... ');
        });