angular2-routing

Removing header and footer when displaying logout page

梦想与她 提交于 2019-11-29 01:00:18
问题 I have added below code in my app.component.html <app-header ></app-header> <router-outlet></router-outlet> <app-footer ></app-footer> and in my routing file I am using below code import { Routes, RouterModule } from '@angular/router'; const appRoutes: Routes = [ { path: '', component: Home }, { path: 'temp', component: TempComponent }, { path: 'temp2', component: TempComponent2 }, { path: 'logout', component: LogoutComponent }, { path: '**', redirectTo: '' } ]; export const routing =

Angular2 with matrix url notation

拟墨画扇 提交于 2019-11-29 00:05:50
问题 Is the matrix url notation the "default" to creating urls with parameters or is better to use the "old" notation with ? and &. I didn't understand it on the angular.io documentation localhost:3000/heroes;id=15;foo=foo or localhost:3000/heroes?id=15&foo=foo 回答1: Matrix parameters are tied to a path segment, while query parameters are tied to the URL. They have different semantics. Use whichever one is more appropriate. (see links in "see also" below"). Maybe it's hard to tell because you

Angular2: How to find out what was previous page url when using angular2 routing

旧街凉风 提交于 2019-11-28 23:35:47
I am developing an angular2 app and I use router. I am in a page /myapp/signup. after signup I navigate the use to /myapp/login. /myapp/login can also be navigated from my home page which is /myapp. So now, when the user users /myapp/login I go back. This can be done by using location.back(). But I dont want to go back when the user is coming from /myapp/signup. So I should check if the user is coming from /myapp/signup and if so, I want to direct it to somewhere else. How can I know the previous url so that I direct the user to a specific state based on that ? Günter Zöchbauer The pairwise

How do I re-render a component manually?

你离开我真会死。 提交于 2019-11-28 23:04:46
I'm a newcomer to Angular2, I'm used to the Angular 1 digest cycle, meaning if I update the scope of a view I can manually trigger a digest by calling $scope.$digest() . However, I'm not sure how to do this in Angular2, esp given that the new framework doesn't have the implicit data binding that the old version had. Here's my problem. I have a route that loads a component when a url with a parameter is hit: // Router export const AppRoutes : RouterConfig = [ { path: 'my/:arg/view', component: MyComponent } ] Then I have this component: // Component export class MyComponent { constructor

RangeError: Maximum call stack size exceeded Lazy routing Angular 2

时间秒杀一切 提交于 2019-11-28 22:23:43
I'm trying to implement lazy routing into my app. I have a very big project and when it was at router-deprecated I used AsyncRoute, but now it was removed. So I tried to implement newest lazy loading, but I got an issue RangeError: Maximum call stack size exceeded What I'm doing wrong? I did all code like in instructions. Take a look please EncountersModule import { NgModule } from '@angular/core'; // import { CommonModule } from '@angular/common'; /* --------------- !System modules --------------- */ import { SharedModule } from 'sharedModule'; //There is a lot of shared components/directives

Angular 2 - Check current active route “name”

房东的猫 提交于 2019-11-28 22:14:54
问题 I am having an Angular 2 application with several nested children view. But it will be displayed on the same page though several router-outlet . const routes: Routes = [ { path: 'queue/:date/:offset/:type', component: BundleListComponent, resolve: { response: BundleListResolve }, children: [ { path: ':bundleId', component: PointListComponent, resolve: { response: PointListResolve }, children: [ { path: ':pointId', component: TaskListComponent, resolve: { response: TaskListResolve }, children:

Angular2 - Redirect to calling url after successful login

空扰寡人 提交于 2019-11-28 21:18:34
I have my application up and running with Angular 2.1.0. The routes are protected via router Guards, canActivate. When pointing the browser to a protected area like "localhost:8080/customers" I get redirected to my login page just like expected. But after a successful login, I would like to be redirected back to calling URL ("/customers" in this case). The code for handling the login looks like this login(event, username, password) { event.preventDefault(); var success = this.loginService.login(username, password); if (success) { console.log(this.router); this.router.navigate(['']); } else {

Angular 2 / leaflet map, How to link to a component from marker popup ? … routerLink?

眉间皱痕 提交于 2019-11-28 20:58:09
Inside my angular 2 app I have a leaflet map with a popup bound to a onClick event. The content of the popup has a link to an angular component. however when I use routerLink inside the .setContent() function the link doesn't show. I'm guessing this is happening because .setContent() is not able to render angular 2 directives which makes sense. what can I use instead? @Component({ selector: 'app-map', templateUrl: './map.component.html', styleUrls: ['./map.component.css'] }) export class MapComponent implements AfterViewInit { openmap: any; constructor() { } ngAfterViewInit() { let openmap = L

Angular 2 Routing Does Not Work When Deployed to Http Server

我是研究僧i 提交于 2019-11-28 18:37:26
I am going to develop a simple Angular 2 application. I have created a project with routing, using Angular CLI and added several components to the app using 'ng generate component ' command. Then I specified routing in the app-routing.module.ts as following. import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { HomeComponent } from './home/home.component'; import { AboutComponent } from './about/about.component'; import { UserComponent } from './user/user.component'; import { ErrorComponent } from './error/error.component'; import {

Navigating to the same route not refreshing the component?

不打扰是莪最后的温柔 提交于 2019-11-28 18:34:07
I've upgraded to use the new Angular 2 router from router-deprecated and some behavior has changed. The page I'm having issues with is a search page. We've chosen to put all the search terms in the URL using the HashLocationStrategy . The routes look like this: const routes: RouterConfig = [ { path: '', component: HomeComponent }, { path: 'search/:term/:cat/:page/:sort/:size/:more', component: HomeComponent }, { path: 'search/:term/:cat/:page/:sort/:size', component: HomeComponent }, { path: 'search/:term/:cat/:page/:sort', component: HomeComponent }, { path: 'search/:term/:cat/:page',