简体   繁体   中英

routing and links angular2

I'm going to be crazy with routing, since angular2 RC1 i cannot route correctly, the last error i have is :

EXCEPTION: Error: Uncaught (in promise): Component 'LoginForm' does not have route configuration

My code is bellow (i hoppe the usefull parts)

I cannot understand the message of error, what i want is just some links available on my main page using the '[routerLink]' routing to the correct components (my main activities)

Regards

Note : "/app/" is just a base path for my app urls (it does not correspond to a component)

bootstrap(AppComponent,[
    ROUTER_PROVIDERS
]);


/////////////////////

@Component({
    selector: 'my-app',
    template: `
    <navbartop></navbartop>
    <h1>MAIN APP COMP</h1>
        <a [routerLink]="['/app/coursesactivity']">CouresesActivity</a>
        <router-outlet></router-outlet>
    `,
    directives: [ROUTER_DIRECTIVES, NavBarTop],
    providers: [ROUTER_PROVIDERS]
})

@Routes([
    { path: '/app/login', component: LoginForm },
    { path: '/app', component: LoginForm }
])

export class AppComponent implements OnInit, OnActivate {
.....
}

/////////////////////

@Component({
  selector: 'loginform',
  templateUrl: '/app/components/compLoginForm/LoginForm.component.html',
  styles: ['/app/components/compLoginForm/LoginForm.component.css']
})

export class LoginForm implements OnInit {//, OnActivate { 
  constructor(
    //private _router: Router
    //private _routeData: RouteData, deprecated
    //private _routeParams: RouteParams deprecated
    ) {    
  }
...

}

I decided to cleanup the code, i encountered other errors, finally i don't know where the original error came from... Sorry for thos who helped me. Regards

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM