last day (15 days later) » 

11:37
0
A: RouterModule : Cannot read property 'forRoot' of undefined

Sangwin GawandeYou need to define routes like following and then add them to RouterModule.forRoot(routes). import { RouterModule, Routes } from '@angular/router'; import { HomeComponent } from './home/home.component'; import { LoginComponent } from './login/login.component'; //Routes const routes : Routes = ...

I don't have routes. I want query parameters, that's why i used router.
Have you tried using ActivatedRoute ?
I used ActivatedRoute in my service to read query parameters.
You can use ActivatedRoute to get query params easily. - codecraft.tv/courses/angular/routing/parameterised-routes
One of the blog given this code to read query params using ActivateRoute.
For ActivatedRoute do i need to import RouterModule ??
11:37
I don't know. Can you try that. I think it should work. because ActivatedRoute is an Interface angular.io/api/router/ActivatedRoute
I tried that. But it's giving error No provider for ActivatedRoute
7
Q: No provider for ActivatedRoute - Angular 2 RC5

Thorsten WestheiderAfter upgrading to Angular 2 RC5 (from RC4) it seems I can no longer inject ActivatedRoute into my components. ORIGINAL EXCEPTION: No provider for ActivatedRoute! Here's the relevant piece of code: import { Component } from '@angular/core'; import { ActivatedRoute } from '@angular/rout...

Why don't you want to use routes? And if there are no routes then How are you getting query params in route?
I am adding query params from another html page to this html page. i have one service to read those params and store it.
12:02
Can't you use default javascript? Like window.location
Yes I can. I was doing it in angular 1.x by $location. So i am finding equivalent to it.
Edited my question. Added code of service which is reading query params.
Service code is working without RouterModule?
no. Giving error No provider for ActivatedRoute
Okay, let's just do one thing
Add this
//Routes
const routes : Routes = [
{
path: '',
component: AppComponent
}
}
This will be only one route
so the application will work as it is
Import this again : RouterModule.forRoot(routes) // You need to add this
12:13
I have edited answer as well
did AppComponent means my component ??
** Error: Can't resolve all parameters for Router **
Yes
did AppComponent means my component ??
-- Yes
from 2.0.0-rc2
one more thing i upgraded router version to 3.4.10 from 2.0.0-rc2
Now getting this error Error: Can't resolve all parameters for Router .
12:24
Did you add this in component?
import { RouterModule, Routes ,Router,ActivatedRoute} from '@angular/router';
yes.
I think error is for Router added into provieder.
Why would you add Router in providers?
Given in one of the tutorial.
I will remove and check
12:42
Hi there
Hi vikram
Glad someone is there :)
i wonder if you can help me Kaustubh
let me explain my requirement
I am working on a angular app which is a SASS product means mutliple vendors have their app on their subdomains
like A and B have their app on a.app.com and b.app.com but both apps are managed with single folder
but with htaccess and some other routing methods
However all users have a single login page on login.app.com and once they fill in the username and password they will be redirected to their on subdoamin
all is working fine but only part not working is passing the response after login to new subdomain
means for login I use a api which returns a response and based on this response users will be redirected to subdomain and i need that response on subdomain as well
Let me know if you get this and have any suggestion
Thanks in advance for giving me your time
:)
13:04
@SangwinGawande Removed Router.
Now i am getting another error Cannot find primary outlet to load 'FormContainerComponent'
Can you post your my.component.ts
13:33
<route-outlet></route-outlet> added into my.component. Now its working
 
2 hours later…
15:29
Yes
You need to add that for routing to work
:)

last day (15 days later) »