angular-routing

ngOnInit not being called after router.navigate

元气小坏坏 提交于 2019-12-01 15:53:09
My Angular app is all of a sudden not calling ngOnInit() after router.navigation() which means my components do not load correctly. I thought it may have been due to some changes I made but reverting the changes did not resolve the issue. Example where normal navigation causes component not to load correctly; This page is navigated to by the following code listing: this.router.navigate(['/result', this.params.data._id]); : Reloading the page, the component is loaded correctly: Here are some of my code listings, app.module.ts @NgModule({ imports: [ BrowserModule, FormsModule, AppRoutingModule,

Still getting 'Not Found' when manually refreshing with angular.js route

白昼怎懂夜的黑 提交于 2019-12-01 15:41:34
After reading a ton of write-ups and stackoverflow questions on Angular.js route, I'm still getting the 'Not Found' error when I do a manual refresh. Steps: browse to localhost --> because of my configuration (below), I'm taken to localhost/home . Views and everything load fine. hit refresh in the browser --> browser displays this Not Found: the requested /home is not found on this server This question is probably most like Refreshing page gives "Page not found" My configuration // Routing configuration. angular.module('myModule') .config(['$routeProvider', '$locationProvider', function (

Angular 2 Duplicate Header

孤人 提交于 2019-12-01 12:54:34
Duplicate header issue occurs, while using the <router-outlet></router-outlet> in the AppComponent Template. I'm using 'angular 2.0.0-rc.6' and 'router 3.0.0-rc.1' Does anyone have any idea, why is this happening? Brandyn Bayes The application is showing two headers on start because your default path is set to be your AppComponent, which has the header included. That path is shown inside of another AppComponent, which you started in your app.module.ts in the bootstrap field. You can resolve this by replacing your default path with another component. Please also make sure to upgrade your

Angular 2 Duplicate Header

守給你的承諾、 提交于 2019-12-01 10:23:32
问题 Duplicate header issue occurs, while using the <router-outlet></router-outlet> in the AppComponent Template. I'm using 'angular 2.0.0-rc.6' and 'router 3.0.0-rc.1' Does anyone have any idea, why is this happening? 回答1: The application is showing two headers on start because your default path is set to be your AppComponent, which has the header included. That path is shown inside of another AppComponent, which you started in your app.module.ts in the bootstrap field. You can resolve this by

AngularDart: Namespace of route names hierarchical too?

倾然丶 夕夏残阳落幕 提交于 2019-12-01 09:35:58
问题 Consider the following initialization of hierarchical routes (excerpt from the AngularDart tutorial): router.root ..addRoute( name: 'add', path: '/add', enter: view('view/addRecipe.html')) ..addRoute( name: 'recipe', path: '/recipe/:recipeId', mount: (Route route) => route ..addRoute( name: 'view', path: '/view', enter: view('view/viewRecipe.html')) ..addRoute( name: 'edit', path: '/edit', enter: view('view/editRecipe.html')) ..addRoute( name: 'view_default', defaultRoute: true, enter: (_) =>

Angular 2, How to pass an array to the Router using queryParams

喜欢而已 提交于 2019-12-01 08:44:07
Is there some way to get this kind of url in Angular 2? http://www.domain.com/the-route?param[]=value1&param[]=value2&param[]=value3 I'm trying to do it like it should be, using queryParams with the Router , but as queryParams accepts an Object I can't do this: this.router.navigate(['/the-route'], queryParams: { 'param[]': 'value1', 'param[]': 'value2', 'param[]': 'value3' }); Because, of course, I can't use the same name ( param[] ) several times in the Object I'm struggling how to do this, but can't find a way I've seen this post: Angular 2 pass array to router queryString . But there are no

Angular 2, How to pass an array to the Router using queryParams

我们两清 提交于 2019-12-01 06:54:43
问题 Is there some way to get this kind of url in Angular 2? http://www.domain.com/the-route?param[]=value1&param[]=value2&param[]=value3 I'm trying to do it like it should be, using queryParams with the Router , but as queryParams accepts an Object I can't do this: this.router.navigate(['/the-route'], queryParams: { 'param[]': 'value1', 'param[]': 'value2', 'param[]': 'value3' }); Because, of course, I can't use the same name ( param[] ) several times in the Object I'm struggling how to do this,

Dynamically loading AngularJS modules from within Templates (Views)

谁说我不能喝 提交于 2019-12-01 04:53:05
Background: Let's suppose for the sake of argument that you have 100,000 views (partials). Let's also suppose you have accompanying view-scoped controllers, and potentially view-scoped services and filters as well. Try to envision an aggregating application that hosts 100,000 disparate small applications. Issue: When you have "partials" that require accompanying controllers, the typical solution is to do something like this: $routeProvider.when('/app1', { templateUrl: 'partials/view1.html', controller: 'controller1' }); The controller is typically loaded from index.html via: <script src="js

Angular 2 Jasmine Can't bind to 'routerLink' since it isn't a known property of 'a'

孤人 提交于 2019-12-01 02:42:22
I'm creating a unit test for my Navbar Component and I'm getting an error: Can't bind to 'routerLink' since it isn't a known property of 'a' Navbar Component TS import { Component } from '@angular/core'; import { Router } from '@angular/router'; import { NavActiveService } from '../../../services/navactive.service'; import { GlobalEventsManager } from '../../../services/GlobalEventsManager'; @Component({ moduleId: module.id, selector: 'my-navbar', templateUrl: 'navbar.component.html', styleUrls:['navbar.component.css'], providers: [NavActiveService] }) export class NavComponent { showNavBar:

Dynamically loading AngularJS modules from within Templates (Views)

给你一囗甜甜゛ 提交于 2019-12-01 02:25:57
问题 Background: Let's suppose for the sake of argument that you have 100,000 views (partials). Let's also suppose you have accompanying view-scoped controllers, and potentially view-scoped services and filters as well. Try to envision an aggregating application that hosts 100,000 disparate small applications. Issue: When you have "partials" that require accompanying controllers, the typical solution is to do something like this: $routeProvider.when('/app1', { templateUrl: 'partials/view1.html',