Home How to update base relative URL in angularapp?
Reply: 2

How to update base relative URL in angularapp?

Zombies
1#
Zombies Published in 2018-02-13 16:17:47Z

So I have an existing angular app which routes/imports (eg: href and src) from the root path only (ie: /). So the app loads up at http://localhost:8080/ and and the base url is /. I want to change it to be http://localhost:8080/myapp/ so all links will then prefixed with /myapp.

I tried updating this code here from (it's in a Java jsp called app.jps):

<head>
    <base href="/" />

to

<head>
    <base href="/myapp" />

But this did nothing, I still get errors like this (and others like it): angular.js:11630 GET http://localhost:8080/angularapp/home/home.html?version=4 404 ()

There are many other errors like this, and the page is just blank (white) so far. Do I have to go and piecemeal edit all these urls to include /myapp in front of it? OR is there a better way?

More info:

Template Urls look like this (in app.module.js):

    $stateProvider
        .state('home', {
            url: '/',
            templateUrl: '/angularapp/home/home.html?version=' + window.version,
            controller: 'HomeCtrl',
            controllerAs: 'vm'
        })
Arihant Jain
2#
Arihant Jain Reply to 2018-02-13 16:28:19Z

It seems like you are missing the end slash.

<head>
<base href="/myapp/" />

Please update href to "/myapp/", that should work.

DeclanMcD
3#
DeclanMcD Reply to 2018-02-14 09:48:00Z

If you change your templateUrl to:

templateUrl: './angularapp/home/home.html?version=' + window.version,

it should take it as a relative path. Try that and see what it gives you (assuming your base url already comes off http://localhost:8080/myapp/).

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.30197 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO