相关疑难解决方法(0)

Angular 2:'...'的路由生成器未包含在传递的参数中

所以我在AuthenticationService中有以下代码.检查登录凭据后,用户将被重定向到其配置文件:

authentication.service.ts:

redirectUser(username:string):void {
  // Redirect user to profile on successful login
  this.router.navigate(['../Profile/Feed', {username: username}]);
}
Run Code Online (Sandbox Code Playgroud)

这一切都很好,但自从我在里面引入了一些子路由后ProfileComponent,我遇到了一些错误.首先,这是我的AppComponent与RouteConfig:

app.ts:

import {Component, ViewEncapsulation} from 'angular2/core';
import {RouteConfig,ROUTER_DIRECTIVES} from 'angular2/router';
import {HTTP_PROVIDERS} from 'angular2/http';

import {HomeComponent} from '../home/home';

import {AuthenticationService} from '../../services/authentication.service';
import {LoginComponent} from '../login/login';
import {ProfileComponent} from '../profile/profile';
import {ProfileService} from '../../services/profile.service';

@Component({
  selector:      'app',
  viewProviders: [AuthenticationService, ProfileService, HTTP_PROVIDERS],
  encapsulation: ViewEncapsulation.None,
  directives:    [
    ROUTER_DIRECTIVES
  ],
  templateUrl:   './components/app/app.html'
})

@RouteConfig([
  {path: '/', component: HomeComponent, as: 'Home'},
  {path: '/inloggen', …
Run Code Online (Sandbox Code Playgroud)

angular2-routing angular

6
推荐指数
1
解决办法
1534
查看次数

标签 统计

angular ×1

angular2-routing ×1