Uncaught SyntaxError: none) after an argument list using AngularJS

I get a syntax error:

Uncaught SyntaxError: missing) after argument list

From this AngularJS code:

dataProvider.CustomAssets.save({
    'product'   : product.id,
    'store'     : store.id
})
.then(function(asset){
    $scope.product.assets.key.push(
        name            : asset[0],
        additionalPrice : asset[1],
        file            : asset[2],
        attribute       : asset[3]
    );
})
.catch(function(error){
    $log.error(error);
});

What errors cause an AngularJS Syntax error?

+4
source share
1 answer

You will forget to wrap the object with {}.

 $scope.product.assets.key.push(
        name            : asset[0],
        additionalPrice : asset[1],
        file            : asset[2],
        attribute       : asset[3]
    );

try it

 $scope.product.assets.key.push({
        name            : asset[0],
        additionalPrice : asset[1],
        file            : asset[2],
        attribute       : asset[3]
    });
+3
source

Source: https://habr.com/ru/post/1620951/


All Articles