This is my setup:
import {bootstrap} from 'angular2/platform/browser';
import {Component} from 'angular2/core';
import {LocationStrategy, APP_BASE_HREF, HashLocationStrategy, ROUTER_DIRECTIVES, Router, RouteConfig, ROUTER_PROVIDERS} from 'angular2/router';
import {HomeComponent} from "../components/HomeComponent";
import {provide} from "angular2/core";
@Component({
selector: 'app',
template: `<a [routerLink]="['/Home']">Home</a>
<router-outlet></router-outlet>`,
directives: [ROUTER_DIRECTIVES]
})
@RouteConfig([
{ path: '/', component: HomeComponent, name: 'HomeComponent' }
])
class RootComponent {
constructor(router:Router) {
}
}
bootstrap(RootComponent, [ROUTER_PROVIDERS, provide(LocationStrategy, {useClass: HashLocationStrategy})
, provide(APP_BASE_HREF, {useValue: '/'})]);
and I keep getting this error, any help is appreciated
I am using latest Beta.0
regards
Sean
I had met same issue,but I resolved by using the same component name used in the component definition and when import the component,eg:
definition
import {Component} from 'angular2/core';
@Component({
selector: 'register-page',
template: `
<h4>Register</h4>
`
})
export class RegisterPageComponent {
//public hero: Hero;
}
import
import {RegisterPageComponent} from './register.component';
@RouteConfig([
{path: '/register', name: 'Register',component: RegisterPageComponent}
])
I met the same issue when I tried to change the component name on import eg: issue
import {RegisterComponent} from './register.component';
/*remove`Page` from the name ,it should be RegisterPageComponent*/
route
@RouteConfig([
{path: '/register',name:'Register',component:RegisterComponent}
])
I had the same issue. My import was not surrounded by curly braces, so it was undefined.
The problem is the cryptic error message, which should state that the component you provided is undefined
for the @RouteConfig
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With