javascript - Relatives and absolute url when doing http.get in angular -


i'm new angular , it's being hard work things. i'm using latest angular ( version 4 ). have scenario :

  1. my backend rest services in baseurl/contextws
  2. my angular application in baseurl/contextfront
  3. the base tag href attribute pointing /contextfront
  4. both angular application , backend in same server (baseurl)
  5. the angular application embedded in iframe (because referenced application) .

now lets want call baseurl/contextws/myservice angular application. how can ?

i can't this.http.get('/contextws/myservice') because angular app translate baseurl/contextfront/contextws/myservice wrong.

i tried build url :

var url 'http://' + location.host +':' + location.port + '/contextws/myservice'; this.http.get(url); 

this works in application, when app referenced in iframe gives me error "undefined".

any appreciated.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -