Search code examples
angularjs-service

AngularJS rest service ignoring port number


In AngularJS, I have defined a service

ngnServices.factory('Logon', ['$resource', function ($resource) {

    return $resource("http://localhost:8080/logon", {}, {
        get: {method: 'GET', cache: false, isArray: false},
        save: {method: 'POST', cache: false, isArray: false},
        update: {method: 'PUT', cache: false, isArray: false},
        delete: {method: 'DELETE', cache: false, isArray: false},
    });

However, when I try to call the defined 'get' method, Angular uses the URL 'http://localhost/logon', ignoring the port.

Any suggestions?


Solution

  • the colon ":" is stripped and angular will trim what is after it, so you will need to escape it to make angular understand that it is a part of the string like doing

    "http://localhost\\:8080/logon"