资源角度尾部斜杠 [英] Angular trailing slash for resource

查看:139
本文介绍了资源角度尾部斜杠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的API需要API调用一个尾随斜线。我不知道如何实现自己的目标与棱角分明。

My api requires a trailing slash for api calls. I was wondering how to pull that off with angular.

所以我需要能够访问 /任务/ /任务/ XXXX /.我试图通过这样做:

So i need to be able to access /tasks/ or a /tasks/xxxx/. I attempted to do it via:

angular.module('taskServices', ['ngResource']).
        factory('Tasks', function($resource){
            return $resource('/tasks/:task_id/', {}, {
                 query: {method:'GET', 
                         params:{},
                         isArray:true}
            });
 });

$scope.tasks = Tasks.query(); 

但它/任务或任务/ XXX 查询。

我怎么能强迫它始终是 /任务/ /任务/ XXX /

How can i force it to always be /tasks/ and /tasks/xxx/

推荐答案

这似乎已得到修复:<一href=\"https://github.com/angular/angular.js/pull/5560\">https://github.com/angular/angular.js/pull/5560

您现在可以配置这种方式:

You can now configure it this way:

app.config(function($resourceProvider) {
  $resourceProvider.defaults.stripTrailingSlashes = false;
});

这篇关于资源角度尾部斜杠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆