Skip to content

getting errors when i generate a route #629

Closed

Description

@rahulbats

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)

Activity

  1. jyaede commented on May 4, 2016

    @jyaede

    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

  2. rahulbats commented on May 5, 2016

    @rahulbats
    Author

    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

  3. rahulbats commented on May 5, 2016

    @rahulbats
    Author

    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.

  4. rcollette commented on May 5, 2016

    @rcollette

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

  5. added 2 commits that reference this issue on May 5, 2016
    bd09056
    69174d5
  6. angular-automatic-lock-bot commented on Sep 5, 2019

    @angular-automatic-lock-bot

    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.

  7. locked and limited conversation to collaborators on Sep 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions