在工厂中使用参数

时间:2015-01-20 14:36:59

标签: javascript angularjs

我想在工厂创建一个功能。但我不明白如何通过我的参数。

如何在参数q中设置动态参数?

app.factory('Item', ['$resource',
    function($resource){
        return $resource(ApiUrl('items/:id'), {}, {
            get:    { cache: false },
            getWithName: { params: {q: 'tshirt'}, isArray: true, cache: false },
            query: { isArray: true, cache: true }
        });
    }
]);

// Code Sample
$scope.items = Item.getWithName(q:$route.current.params.name);

1 个答案:

答案 0 :(得分:0)

$scope.items = Item.getWithName({q:$route.current.params.name});