AngularJS - $resource different URL for Get and Post

前端 未结 5 1490
南笙
南笙 2020-12-24 14:35

$resource is awesome providing very convenient way to handle web services. What if GET and POST have to be performed on different URLs?

For example, GET URL is

5条回答
  •  一个人的身影
    2020-12-24 14:57

    Use 'url' property of [actions] to override the default url.

    $resource(url, [paramDefaults], [actions], options);
    

    for example:

    $resource('http://localhost/pleaseGethere/:id',{},{
        getMethod:{
            method:'GET',
            isArray:true
        }
        postMethod:{
            url:'http://localhost/pleasePosthere',
            method:'POST',
            isArray:false
        }
    }
    

    Usage of Angular $resource: http://docs.angularjs.org/api/ngResource/service/$resource

提交回复
热议问题