153 questions
398
votes
9
answers
643k
views
Send data through routing paths in Angular
Is there anyway to send data as parameter with router.navigate?
I mean, something like this example, as you can see the route has a data parameter, but doing this it's not working:
this.router....
272
votes
14
answers
278k
views
Angular 2 optional route parameter
Is it possible to have an optional route parameter in the Angular 2 route? I tried the Angular 1.x syntax in RouteConfig but received below error:
"ORIGINAL EXCEPTION: Path "/user/:id?" contains "?"...
189
votes
25
answers
316k
views
Angular 5 Scroll to top on every Route click
I am using Angular 5. I have a dashboard where I have few sections with small content and few sections with so large content that I am facing a problem when changing router while going to top. Every ...
93
votes
4
answers
67k
views
Best method to set different layout for different pages in angular 4
I am new to angular 4. What I'm trying to achieve is to set different layout headers and footers for different pages in my app. I have three different cases:
Login, register page (no header, no footer)...
283
votes
14
answers
348k
views
Angular: How to update queryParams without changing route
I am trying to update (add, remove) queryParams from a component. In angularJS, it used to be possible thanks to :
$location.search('f', 'filters[]'); // setter
$location.search()['filters[]']; // ...
68
votes
12
answers
105k
views
How do you mock ActivatedRoute
I'm learning Angular and I want to do tests, but I'm stuck. I've got a function:
ngOnInit(): void {
this.route.paramMap
.switchMap((params: ParamMap) =>
this.SomethingService....
26
votes
7
answers
59k
views
Angular 2 Routing navigate run in new tab(Use Angular Router naviagte )
How to open a new browser Tab , if using router.navigate .
this.router.navigate([]).then(result => { window.location.href = link; });
21
votes
4
answers
12k
views
Redirect all URLs with hash to Angular Routes without hash
I'm replacing an existing AngularJS 1.6.x SPA with an Angular 5.x SPA and I want to make the change transparent to my users.
I'm concerned about users who have bookmarks to the existing app because ...
45
votes
3
answers
84k
views
Angular Passing Data Between Routes
I have a little problem using routes in angular 4. You know, when I am trying to pass data from a component to another using navigate('root', data), I just received [object Object],[object Object],[...
43
votes
5
answers
37k
views
Navigation ID is not equal to the current router navigation id error
I'm using @ngrx/router-store in my Angularv5 app and I recently started running into a an error: Navigation ID X is not equal to the current navigation id Y (where X and Y are integers).
This problem ...
31
votes
9
answers
29k
views
How to get all route params/data
Given a route config
{
path: '/root/:rootId',
children: [{
path: '/child1/:child1Id',
children: [{
path: '/child2/:child2Id
component: TestComponent
}]...
17
votes
3
answers
67k
views
How to use angular 6 Route Auth Guards for all routes Root and Child Routes?
How to use angular 6 Route Auth Guards for all routes Root and Child Routes ?
8
votes
2
answers
17k
views
Get route parameters in component
I am working on the Angular-6 project. I have many child routes for my application. One of them is as follow:
const routes: Routes = [
{
path: 'innovation-track/:innovation-track-id', ...
2
votes
1
answer
5k
views
Angular 5 Build routes from API data at startup
I need to create routes at Angular application startup based on the data received from API (site map).
1. APP_INITIALIZER calls SettingsService.loadSettings to get the data from API
2. Data comes to ...
33
votes
2
answers
39k
views
Routing to static html page in Angular 6+
I have an Angular project with 3 components country, region, home. When I load the home page, I have route setup to HomeComponent, which hyperlinks for routes. Everything works just fine and behaving ...
24
votes
4
answers
14k
views
Angular 2+: How to access active route outside router-outlet
I have an Angular 5 application.
I have the following code in my app component.
I want to hide navbar and topbar for particular routes.
Is it possible to get currently activated route in app....
17
votes
4
answers
51k
views
Angular 6 - Get current route and its data
How to get the current route you're in and its data, children and parent?
If this is the route structure:
const routes: Routes = [
{path: 'home', component: HomeComponent, data: {title: 'Home'}},...
10
votes
2
answers
14k
views
What is the difference between HTML base href and Angular APP_BASE_HREF?
I'm working on an Angular app where I'm faced with setting an HTML base href value, and/or an APP_BASE_HREF value.
What is the difference and relation between these?
8
votes
3
answers
24k
views
Ionic 4 Angular router navigate and clear stack/history of previous page
I'm developing an app using Ionic 4 with Angular router. I would like to navigate to another page and clear the page stack. In Android native, it's something like this:
Intent intent = new Intent(...
8
votes
1
answer
11k
views
How to implement multi-level routing in Angular?
I'm working on a little project of mine in order to learn something more about Angular, but I really cannot figure out how to implement a multi-leveled routing.
I've read the documentation about the ...
7
votes
1
answer
2k
views
Accessing Route data in root component, route data is empty
My problem is that I have a lang.component loaded with <router-outlet>. What I need is to access ActivatedRoute params in the root component which is app.component but all route data there is ...
4
votes
2
answers
23k
views
Angular 4 animation for fade in and out a view
I just want the view to fade in and out on route change. I have setup the component correctly it seems but need to get the animation syntax correct I think.
This is my current animation attempt.
I ...
4
votes
2
answers
3k
views
Resolver does not resolve if another data stream is added
I am trying to use a resolver in order to retrieve data depending on the given parameters the route holds.
Unfortunately, the moment I add another data stream that my data depends on the resolver ...
3
votes
2
answers
5k
views
Angular 4 router is appending components on routerLink navigation instead of destroying them
When navigating from within a submodule from a child route to another sibling child route, instead of the router destroying the previous component, it appends the new one on navigation forward and ...
1
vote
1
answer
3k
views
angular4 route issue by adding '%2f' character before path
reason of using nested route for me is handling dynamically icon and back button for every page.i have abstract route because when i click to back button route params disappear and i put an abstract ...