angular2-routing

Angular 2 Child Routing (v3) 'Cannot read property 'annotations' of undefined'

与世无争的帅哥 提交于 2019-12-12 11:26:53
问题 I'm trying to play around in Angular 2 and get a test app running but I'm having some problems getting the routing to work in the latest version of the router (3.0.0 alpha-7). main.ts: import {bootstrap} from '@angular/platform-browser-dynamic'; import {AppComponent} from './app.component'; import {APP_ROUTER_PROVIDERS} from './app.routes'; bootstrap(AppComponent, [APP_ROUTER_PROVIDERS]); app.component.ts: import {Component} from '@angular/core'; import {ROUTER_DIRECTIVES} from '@angular

Angular 2 RC 2 How to Inject Router into Custom ExceptionHandler

淺唱寂寞╮ 提交于 2019-12-12 10:59:25
问题 I'm using Angular 2 RC2. I need to inject the Angular 2 Router into my custom ExceptionHandler class. However I get the following error Error: Error: Cannot resolve all parameters for 'ErrorHandler'(?). Make sure that all the parameters are decorated with Inject or have valid type annotations and that 'ErrorHandler' is decorated with Injectable. I did try decorating private router: Router with @Inject to no avail. I'm using typescript, hence I don't think I need the @Inject attribute here. My

ASP.Net Core + Angular 2 app /home routing

不想你离开。 提交于 2019-12-12 10:49:51
问题 I've been fighting with this for a while now and decided to write a post. I'm building a simple Single Page Application using VS2017 on ASP.Net Core 5.0 and Angular 2 over a template taken from ASP.NET Core Template Pack. The app is supposed to manage a contact list database. The idea I have in mind is that the default starting '/home' page should be displaying the list of contacts using HomeComponent. All routing works fine, but when app is getting started or whenever I'm trying to route to

Angular 2 Router how to hide browser url parameter Id's and give alias names

好久不见. 提交于 2019-12-12 10:07:28
问题 How do I route to employeeDetail/23 but represent to the user an alias URL like /EmployeeDetails ? Background I'm trying to implement Angular 2 routing and when I went to the detail section I see: http://localhost:3444/employeedetail/23. Here I want to hide that 23 on the browser URL. Example http://plnkr.co/edit/QgehylornOgXhTaZX8Yn?p=preview {path: 'crisis-center/:id/:id2', component: CrisisDetailComponent} I want to hide those IDs on the browser URL and instead present an alias route name.

Angular2 how can i pass a question mark and some words in my url

余生颓废 提交于 2019-12-12 10:02:18
问题 hello i am trying to add some string parameters to the navigation url like this this.router.navigate(['/merchant/setpassword?acc='+response.infoCode]); but when i am using this is redirecting me to /merchant/setpassword%3Facc%3DeyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJtZXppYW4iLCJjb3VudHJ5IjoiOTYiLCJjcmVhdGVkIjoxNTAwMzExODk2MDQ5LC My problem lies in %3Facc%D i want this to become ?acc= 回答1: Try this, this.router.navigate( [ 'url', { id: 'companyId', param1: 'value1' }]); Check, How to handle query

Nested routing in Angular 2/4

↘锁芯ラ 提交于 2019-12-12 09:46:33
问题 I work on an app which I intend to have following structure: -MAIN - main “container” (main routes) --NCF (lazy loaded, routes for it’s subapps) ---ACNP (lazy loaded) ----Component1 ----Component2 ---SubApp2 (lazy loaded) ---SubApp3 (lazy loaded) --App2 (lazy loaded) --App3 (lazy loaded) --… It’s starting framework for app which will have 3 levels – MAIN, apps and subapps. Every app and subapp is to be developed independently. In future there may be more lazy-loaded levels. I want routing to

Unable to inject ActivatedRouteSnapshot

拜拜、爱过 提交于 2019-12-12 09:28:29
问题 Injecting ActivatedRouteSnapshot into a component is not working (and neither is injecting ActivatedRoute). Here the stack trace: "Error: Can't resolve all parameters for ActivatedRouteSnapshot: (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?). at SyntaxError.ZoneAwareError (http://localhost:4200/polyfills.bundle.js:7042:33) at SyntaxError.BaseError [as constructor] (http://localhost:4200/vendor.bundle.js:73735:16) at new SyntaxError (http://localhost:4200/vendor.bundle.js:6140:16) at

History forward / backward button doesn't work with angular 2 router

╄→尐↘猪︶ㄣ 提交于 2019-12-12 08:55:09
问题 History( Push State) forward / backward button doesn't work with angular 2 router.I have tested this in Chrome and Firefox both. Forward button works never and Backward button works only for 2 steps than UI doesn't respond according backward button. I have following code. app.component.ts import { Component } from '@angular/core'; import { ROUTER_DIRECTIVES, Routes } from '@angular/router'; import { CrisisListComponent } from './crisis-list.component'; import { HeroListComponent } from '.

why ActivatedRoute in @angular\router params is observable?

青春壹個敷衍的年華 提交于 2019-12-12 07:52:44
问题 why ActivatedRoute in @angular\router params is observable ? I'm wondering why do I need to subscribe for Params ? and why params are async is there a case the componenet of the route will be created but the params still not populated ? and is there a way to just get the value without an observable ? 回答1: You can use route.routerState.params You can subscribe because when your application navigates to the same route with just another parameter value, the component is not recreated and you

Prevent routing in Angular when user manually changes url in browser tab

主宰稳场 提交于 2019-12-12 07:27:09
问题 I am stuck in a issue that happens when user manually changes the route in browser tab and presses enter. This forces my ui-router/angular2-router to navigate to the state entered by user. I want to prevent this and allow routing only through the flow I have implemented by button clicks in my website. 回答1: Its 2018! Angular 5 is here and so is the solution to this issue. BAMM its CanActivate Interface that a class can implement to be a guard deciding if a route can be activated. We can add