After update my app to angular2 to RC4 I am reciving this error. I have LoginService
injected into AppComponent
in new webpack starter bundle.
I was trying to inlcude AppComponent
in routes, but it won't works.
Also I was including LoginService
inside index.ts with APP_PROVIDERS but I am getting another error
Invalid provider - only instances of Provider and Type are allowed, got: undefined
Also putting LoginService
in bootstrap, but without effect.
What is wrong with Angular2 in RC4 ? Components are not in the tree anymore?
This is my router config for router "3.0.0-beta.2" :
export const routes: RouterConfig = [
{ path: '', component: StartPageComponent },
{ path: 'login', component: StartPageComponent },
{
path: 'dashboard', component: 'DashboardComponent',
canActivate: [WebpackAsyncRoute],
children: [
{ path: '', component: 'ContentDesktopComponent' } // must be included
]
},
{ path: '**', component: NoContent }
];
And I wanna have LoginService available for every routes.
My app.component looks like this:
@Component({
selector: 'app',
pipes: [],
providers: [LoginService, SearchService, TasksService],
directives: [RouterActive],
encapsulation: ViewEncapsulation.None,
styles: [
require('!raw!normalize.css'),
require('!raw!../assets/css/animate.css'),
require('./app.component.scss')
],
template: require('./app.component.html')
})
export class App {
constructor(private translate: TranslateService,
public appState: AppState) {
Resource.map(ENDPOINTS.API.toString(), 'http://localhost:3002/api');
let userLang = navigator.language.split('-')[0]; // use navigator lang if available
userLang = /(fr|en)/gi.test(userLang) ? userLang : 'pl';
translate.setDefaultLang('en');
translate.use('pl');
}
ngOnInit() {
}
}
provider are not available for routers... now... in rc4
LoginService:
@Injectable()
export class LoginService {
private user: User = <User>{
avatar_url: '/assets/img/avatars/u6.png'
};
constructor(private rest: Resource<ENDPOINTS, User, User[]>) {
this.rest.add(ENDPOINTS.API, 'users');
}