Code Monkey home page Code Monkey logo

Comments (7)

mgonto avatar mgonto commented on July 19, 2024

Hey @amitava82 I've added custom Operations. Please try them on and let me know what you think :). Maybe you can update blog post with this :).

Bests!

from restangular.

amitava82 avatar amitava82 commented on July 19, 2024

Thanks! Works perfect! How about little pretty way of calling it? Like so:

// Second way of creating Restangular object. URL and ID :)
var account = Restangular.one("accounts", 123);

// GET /accounts/123?single=true
$scope.account = account.get({single: true});

// POST /accounts/123/archive?param=param2 with the body of volume: "bulk"
account.action("archive", "POST", {param: "param2"}, {volume: 'bulk'})

Just throwing some idea!

Cheers!

from restangular.

mgonto avatar mgonto commented on July 19, 2024

The way to do this is pretty similar and I'm following Angular's "convention" like $http.expectPOST

account.customPOST("archive", {param: "param2"}, {}, {volume: 'bulk'})

I use headers as the third param s that the body is only added to the other methods (They all use the same method beneath).

Thanks!

from restangular.

pauldijou avatar pauldijou commented on July 19, 2024

Nice feature. Just my 2cts, but AngularJS "convention" is most of the time starting with a verb, like $http.expectPOST, so what about doing the same in Restangular? It's already the case for some internal functions like isSafe or set... or get....

It's totally personnal, but I find doPost more explicit and less verbose than customPost. What do you think?

from restangular.

mgonto avatar mgonto commented on July 19, 2024

It's totally personnal, but I find doPost more explicit and less verbose than customPost. What do you think?

I like it to. I'm going to add an alias, so that you can use either doPost or customPost

from restangular.

mgonto avatar mgonto commented on July 19, 2024

Fixed and released together with https://github.com/mgonto/restangular#url-building

from restangular.

pauldijou avatar pauldijou commented on July 19, 2024

As fast as ever! Thanks for the quick commit.

from restangular.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.