question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No provider for RouterOutletMap! {NS} 2.1.0

See original GitHub issue

Hi,

I recently upgrade to v2.1.0 and started a new App.

I think there is a bug with the Angular router or maybe the NS_ROUTER_PROVIDERS. Here is the error when i run

 tns run android 

on my Nexus 5x:

JS: EXCEPTION: Error in ./AppComponent class AppComponent - inline template:0:0
JS: ORIGINAL EXCEPTION: No provider for RouterOutletMap!

Here is my Code:

main.ts:

import {nativeScriptBootstrap} from "nativescript-angular/application";
import {AppComponent} from "./app.component";

nativeScriptBootstrap(AppComponent);

and my app.component.ts component :

import {Component} from "@angular/core";
import {RouteConfig} from '@angular/router-deprecated';
import {HTTP_PROVIDERS} from "@angular/http";
import {NS_ROUTER_DIRECTIVES, NS_ROUTER_PROVIDERS} from 'nativescript-angular/router';
import LoginPage from './components/login/login.component';

@Component({
    selector: "my-app",
    directives: [NS_ROUTER_DIRECTIVES],
    providers: [NS_ROUTER_PROVIDERS, HTTP_PROVIDERS],
    template: "<page-router-outlet></page-router-outlet>"
})
@RouteConfig([
     { path: '/Login', component: LoginPage, name: 'Login', useAsDefault: true}
])
export class AppComponent { }

the package.json dependencies :

"dependencies": {
    "@angular/common": "2.0.0-rc.3",
    "@angular/compiler": "2.0.0-rc.3",
    "@angular/core": "2.0.0-rc.3",
    "@angular/http": "2.0.0-rc.3",
    "@angular/platform-browser": "2.0.0-rc.3",
    "@angular/platform-browser-dynamic": "2.0.0-rc.3",
    "@angular/platform-server": "2.0.0-rc.3",
    "@angular/router": "3.0.0-alpha.7",
    "@angular/router-deprecated": "2.0.0-rc.2",
    "nativescript-angular": "0.2.0",
    "tns-core-modules": "^2.1.0"
  },

I remember having the same problem with ng2 a few months ago and solve it by declaring the providers in the bootstrap function of the main.ts file like this:

bootstrap(AppComponent, [
     NS_ROUTER_DIRECTIVES, 
     NS_ROUTER_PROVIDERS
])

But still doesn’t work… Regards

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
DomGaudcommented, Jul 1, 2016

Try import NS_ROUTER_DIRECTIVES, NS_ROUTER_PROVIDERS from "nativescript-angular/router-deprecated/ns-router-deprecated"

import {NS_ROUTER_DIRECTIVES, NS_ROUTER_PROVIDERS} from "nativescript-angular/router-deprecated/ns-router-deprecated";
1reaction
vakrilovcommented, Jul 1, 2016

This was a breaking change we made in the 0.1.7. If you are using the @angular/router-deprecated you should also use the nativescript-angular/router-deprecated.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No provider for RouterOutletMap - angular - Stack Overflow
How I tried to fix this. I tried to add RouterOutletMap to providers in AppModule, exception don't throw, but app don't redirect to...
Read more >
Incident Response - Hybrid Analysis
Submit malware for free analysis with Falcon Sandbox and Hybrid Analysis technology. Hybrid Analysis develops and licenses analysis tools to fight malware.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found