相关疑难解决方法(0)

AngularJS资源:如何禁用url实体编码

在我目前的项目中,我有一个drupal后端,为我的前端公开了休息服务.对我的后端的一些调用并不像url实体那样被编码.

所以我的问题是:如何禁用某些参数的URL编码?

例:

我需要在不同的搜索字词之间用"+"标记我的后端.像这样:

http://backend.com/someservice/search/?terms=search+terms+here
Run Code Online (Sandbox Code Playgroud)

但角度,设置如下:

var resource = $resource(
  backendUrl + '/views/:view', {},
    {
      'search': {params:{view:'searchposts'}, isArray:true}
    }
 );

// search posts for the given terms
this.searchPosts = function(terms, limit) {
  resource.search({search:terms.join('+'), limit:limit});
};
Run Code Online (Sandbox Code Playgroud)

调用以下网址:

http://backend.com/someservice/search/?terms=search%2Bterms%2Bhere
Run Code Online (Sandbox Code Playgroud)

有什么建议?谢谢!

javascript rest angularjs

14
推荐指数
1
解决办法
1万
查看次数

使用$ resource时,ng-Table排序和搜索不起作用

我开始使用ngTable的现有示例,并使用ngResource对其进行了一些修改.使用资源工厂,它填充数据,但搜索和排序不起作用.

http://codepen.io/anon/pen/yVGKMZ

在上面创建了一支笔.

var app = angular.module("myApp", ["ngTable", "ngResource", "ngTableDemoFakeBackend"]);

app.factory('orderResource', function ($resource) {
    return $resource('https://jsonplaceholder.typicode.com/posts');
});

(function () {

    app.controller("demoController", demoController);
    demoController.$inject = ["NgTableParams", "$resource", "orderResource"];
    function demoController(NgTableParams, $resource, orderResource) {
        //debugger;
        var ordersGet = orderResource.query({ });


        var Api = $resource("/data");
        this.tableParams = new NgTableParams({}, {
            getData: function (params) {

                // **** Section 1 ***  sorting and filter does not work
                    return ordersGet.$promise.then(function (response) {
                    params.total(100);
                    return response;
              // **** Section 1 *** 
              
              
                //****Section 2 *** this works fine …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs angular-resource ngtable

5
推荐指数
1
解决办法
1142
查看次数

标签 统计

angularjs ×2

javascript ×2

angular-resource ×1

ngtable ×1

rest ×1