0

In my app componenent, i have the following code

import { Component, OnInit}       from '@angular/core';
import {aComponent} from './a.component';
import {xService} from './shared';
import {Router, Routes, ROUTER_DIRECTIVES, ROUTER_PROVIDERS } from  @angular/router';
import {zComponent} from './z.component';

@Component({
   moduleId: module.id,
   selector: 'my-app',
   templateUrl: 'x.component.html',
   styleUrls: ['x.component.css'],
   directives: [
       ROUTER_DIRECTIVES],
   providers: [
       ROUTER_PROVIDERS, cService
   ]
})
@Routes([
  {
     path: '/',
     component: zComponent
  },
  {
     path: '/admin',
     component: aComponent
  }
 ])
export class AppComponent implements OnInit {


   constructor(private _router: Router) { }

   ngOnInit() {

   }

When I type the following URL urlserver/ it works fine , my zcomponent is displayed But when I type the following url urlserver/admin , an error occurs (The requested URL /admin was not found on this server.)

what's happend ? Why does not the code work ?

Florence
  • 1,641
  • 3
  • 13
  • 23

1 Answers1

1

Probably the problem is rather server-side. Your server have to redirect all the routes to index.html to let Angular make its job.

Wojciech Kwiatek
  • 6,634
  • 2
  • 16
  • 26