1

I'm trying to build a URL in my angular page. Here is a working URL using postman

http://localhost:8080/api/app?user=77787f&path=/&projection=display

To get this to work I'm hard-coding the user and the path for now

so user=77787f path = "/"

My service.js has

function Geneset ($resource) {
        var resourceUrl =  'api/app&:userprojection=display';
and then

return $resource(resourceUrl, {}, {
            'query': { method: 'GET', isArray: false,  
                transformResponse: function(data) {
                    if (data) {
                        data = angular.fromJson(data);
                    }
                    return data;
                }},

I have the following in my controller

vm.user = "7966152e-7637-41fa-bbb6-91ee3fbbc3c7&path=/" vm.path = "/"

function loadAll () {
            app.query({
                user: vm.userId,
                path: vm.path,
                page: pagingParams.page - 1,
                size: vm.itemsPerPage,
                sort: sort()
            }, onSuccess, onError);
            function sort() {
                var result = [vm.predicate + ',' + (vm.reverse ? 'asc' : 'desc')];
                if (vm.predicate !== 'id') {
                    result.push('id');
                }
                return result;
            }

Any easy way to create this? I added a second variable in the GET and that is causing me an issue.

1
  • Which routing that you using in your app? ngroute or ui-router? Commented Nov 19, 2016 at 6:36

2 Answers 2

1

I'm on my phone so I can't type what I want to in full, but you're going to want to take advantage of that empty object in your resource, the second item passed in, have props in there that match your url parameters, and then also match what you pass in when calling query.

Sign up to request clarification or add additional context in comments.

Comments

0

turned on my laptop ... try something like this

return $resource(resourceUrl, {
    user: @user,
    path: @path
}, {
    'query': { method: 'GET', isArray: false, transformResponse: function(data) {
    if (data) {
        data = angular.fromJson(data);
    }
    return data;
}},

you'll need to update this part:

var resourceUrl = 'api/app&user=:user&path=:path&projection=display'

hope that helps...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.