简体   繁体   English

角资源URL始终带有问号

[英]Angular resource url always has question mark

I have an angular resource that I want to generate the url below /api/customerSearch/Search/xxxx 我有一个角度资源,我想在/ api / customerSearch / Search / xxxx下面生成网址

But what I am getting is /api/customerSearch/Search?criteria=xxxx 但是我得到的是/ api / customerSearch / Search?criteria = xxxx

controller 控制者

 core.controller('customerSearchCtrl',
 function customerSearchCtrl($scope, customerSearch) {
 $scope.getCustomerSearchResults = function () {
       $scope.customerSearchResults = customerSearch.get(
                        {
                          crtieria: $scope.searchCriteria 
                        });
 }; });

Resource 资源资源

 core.factory('customerSearch', ['$resource', function ($resource) {
 return $resource('./api/customerSearch/Search/:criteria/');

}]);

Any ideas would be much appreciated 任何想法将不胜感激

Looks like the parameter specified in the controller doesn't match the route template. 看起来控制器中指定的参数与路由模板不匹配。

In the controller it's 'crtieria', in the service it's 'criteria' 在控制器中是“ crtieria”,在服务中是“ criteria”

Edit: To clarify, when angular can't find a match for the property in the route template, the default is to pass all additional parameters as querystring 编辑:澄清一下,当angular在路由模板中找不到该属性的匹配项时,默认值为将所有其他参数作为querystring传递

Looks like the parameter specified in the controller doesn't match the route template. 看起来控制器中指定的参数与路由模板不匹配。

core.controller('customerSearchCtrl',
    function customerSearchCtrl($scope, customerSearch) {
        $scope.getCustomerSearchResults = function() {
            $scope.customerSearchResults = customerSearch.get({
                criteria: $scope.searchCriteria
            });
        };
    });

Define the url as follows: 如下定义URL:

core.factory('customerSearch', ['$resource', function($resource) {
    return $resource('./api/customerSearch/Search/:criteria', { criteria: '@criteria' });
}]);

Hope this will help you. 希望这会帮助你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM