Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting errors when i generate a route #629

Closed
rahulbats opened this issue May 4, 2016 · 5 comments · Fixed by #639
Closed

getting errors when i generate a route #629

rahulbats opened this issue May 4, 2016 · 5 comments · Fixed by #639

Comments

@rahulbats
Copy link

i generated a route using using
ng generate route ROUTE

if i open the app i get lots of errors like this

browser_adapter.js:77 Error: DI Exception
at NoProviderError.BaseException as constructor
at NoProviderError.AbstractProviderError as constructor
at new NoProviderError (reflective_exceptions.js:75)
at ReflectiveInjector_.throwOrNull (reflective_injector.js:776)
at ReflectiveInjector
.getByKeyDefault (reflective_injector.js:804)
at ReflectiveInjector
.getByKey (reflective_injector.js:767)
at ReflectiveInjector
.get (reflective_injector.js:576)
at ElementInjector.get (element_injector.js:23)
at DebugAppView._View_DemocracyAppComponent0.createInternal (DemocracyAppComponent.template.js:24)
at DebugAppView.AppView.create (view.js:66)

@jyaede
Copy link

jyaede commented May 4, 2016

I had the same issue. You need to add ROUTER_PROVIDERS to your bootstrap statement in main.ts

import { bootstrap } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { ROUTER_PROVIDERS } from '@angular/router';
import { DashboardAppComponent, environment } from './app/';

if (environment.production) {
  enableProdMode();
}

bootstrap(AppComponent, [
  ROUTER_PROVIDERS
]);

This worked for me

@rahulbats
Copy link
Author

rahulbats commented May 5, 2016

hi @yaede7 ,
i tried that. It now loads the page fine.
But when i go to the route by typing in the path in the address bar, it does not load the route page , it keeps showing the main html

@rahulbats
Copy link
Author

rahulbats commented May 5, 2016

So i realized this i have to add a router link to my main page to get the routes to work.
<a [routerLink]="['/heroes']">Heroes</a>

Now if i type http://localhost:4200/heroes i actually get to the heroes page. If i remove the link from my main page typing it in address bar does not load the route content.

@rcollette
Copy link

So you can't deep link without having a router link somewhere? Is this a bug?

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants