3xGuy
3xGuy

Reputation: 2559

Configure url path in angular 4

Hello and thank you for taking the time to read this. I am trying to configure the url for the base application, and I just cannot figure out where this is done at.

I want to call it Routing, but I know that this isn't the correct words, so let me do a bit of explanation on what I'm trying to do. We got a template for an MVC application that allowed us to add angular 2 into the app, works great from Visual Studio, we deploy in IIS into its own web site it works. We move it to the default website it no longer works.

With all of that said now I can explain what the issue is, the browser is getting to the application at localhost/Test/ but when it is trying to download the app.component.ts all of the others, it then is trying to goto localhost/app/app.component.js not localhost/Test/app/app.component. Now my questions: where do i configure the url to go to localhost.Test/app...?

import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

import { LoginComponent } from './components/login/login.component';
import { GenerateComponent } from './components/generate/generate.component';
import { NewuserComponent } from './components/newuser/newuser.component';
import { NewlocationComponent } from './components/newlocation/newlocation.component';

const appRoutes: Routes = [
    { path: '', redirectTo: 'login', pathMatch: 'full' },
    { path: 'login', component: LoginComponent },
    { path: 'generate', component: GenerateComponent },
    { path: 'newuser', component: NewuserComponent },
    { path: 'newlocation', component: NewlocationComponent }
];

export const routing: ModuleWithProviders =
    RouterModule.forRoot(appRoutes);

Upvotes: 2

Views: 1283

Answers (1)

Bunyamin Coskuner
Bunyamin Coskuner

Reputation: 8859

You need to set deploy-url option on angular-cli.

Check the docs

You can do it as follows

For serve command ng serve --deploy-url /test/

For build command ng build --deploy-url /test/

Upvotes: 1

Related Questions