I have my main.component.ts
code:
Its location is: root/
import {Component, OnInit, OnChanges, IterableDiffers} from 'angular2/core';
import {TypeService} from './type/type.service';
import {RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router';
import {Router} from 'angular2/router';
@Component({
selector: 'my-app',
providers: [],
directives: [ROUTER_DIRECTIVES],
template: `
<a [routerLink]="['Type']">Type</a>
<router-outlet></router-outlet>
`
})
@RouteConfig([
{path:'/type', name: 'Type', component: TypeService}
])
export class AppComponent{
constructor(private _router: Router){}
}
Then I have my type.component.ts
code:
Its location is: root/type
import {Component, OnInit} from 'angular2/core';
import {DirectoryComponent} from '../main/main.component';
import {RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router';
import {Router} from 'angular2/router';
import {AppComponent} from '../app.component';
import {Http} from 'angular2/http';
@Component({
selector: 'type',
directives: [ROUTER_DIRECTIVES],
template: `<h1>hi</h1>`
})
export class TypeService{
constructor(
private _router: Router) {}
}
When I click the Type link in my main application it takes me to root/type and it loads the type component. However if I press reload it gives me a Not Found error.
How do I make it so I can access components directly via the url?