angular2-routing

How to pause the route change in navigationStart router event

霸气de小男生 提交于 2019-12-24 10:59:57
问题 In my application I have routes exposed from packages (node modules). So i couldn't use canActivate or canDeactivate for the routes defined inside node modules. So I started subscribing to all route change in my app component and based on condition i am redirecting the user to different routes. Since the condition has API call, the route change is not paused in the navigationStart instead it completes the routing to other page and once API call is successful the redirect happens to the other

ng serve error localhost could NOT be bound

拥有回忆 提交于 2019-12-24 10:47:35
问题 I am new in angular 5, I am try to run angular 5 project get following error "ng serve error localhost could NOT be bound". any one can help me. example: D:\workspace\newapp>ng serve Provided host localhost could NOT be bound. Please provide a different host address or hostname Error: Provided host localhost could NOT be bound. Please provide a different host address or hostname`enter code here` at D:\workspace\newapp\node_modules\portfinder\lib\portfinder.js:139:27 at D:\workspace\newapp

Angular 2: Block GET request on a URL

♀尐吖头ヾ 提交于 2019-12-24 09:01:32
问题 I have URLs as http://www.localhost:4200/profile and http://www.localhost:4200/editProfile . Both URLs are served to a logged in user. Now I want the accessibility of /editProfile only through the navigation menu available and not by directly writing the URL on address bar and pressing enter. If the user does so, he is redirected to /profile path. Something similar to allowing POST on /editProfile but no GET. Can it be achieved using CanActivate available at the routes module? Thanks 回答1:

Angular 2 updating URL path params with no redirect

点点圈 提交于 2019-12-24 08:51:03
问题 Using Angular 2 how do you update the URL Path without redirecting the page. I know you can access the params using ActivatedRoute queryParamMap Observable but what if I want to change these values and have those display in the URL. Updating the values in the URL allows for easy bookmark-ability. I don't want to redirect as the query params I am adding are simple data filter I want to store. 回答1: In the component constructor subscribe the query parameter to your model. this.route.queryParams

When is NavigationStart fired in Angular 2?

社会主义新天地 提交于 2019-12-24 08:49:08
问题 Is NavigationStart event fired on page load, after redirection has occurred from an external site to this site? Sample code which is not fired on redirection from external site to SomeComponent. import { Router, ActivatedRoute, NavigationStart } from '@angular/router'; export class SomeComponent { constructor(public _router: Router, private _activeRoute: ActivatedRoute, private _location: Location) { this.router = _router; this.router.events .filter(e => e instanceof NavigationStart)

routerLink to load a page of a nested parent->child->child

岁酱吖の 提交于 2019-12-24 08:42:17
问题 I am trying to use routerLink to load a page of a parent->child->child router outlet with two named outlets. http://localhost:4200/#/output/(output:details/(data:distributions)) 1) If I paste the URL into the browser it works 2) If I use the below it works: this.router.navigateByUrl('output/(output:details/(data:distributions))'); If I try to use router link in an angular2 tab component IT DOES NOT WORK [routerLink]="['/output', {outlets: {'output': ['details'],'data':['distributions']}}]"

angular 2 lazy loading - routes from server

∥☆過路亽.° 提交于 2019-12-24 08:25:06
问题 I have been working on an Angular 2 project using lazy loading. It's working well, but what I need is to get the module name from the server and then create a route, but it's not working. Here is what I have: import { Routes, RouterModule } from '@angular/router'; function getRoutes(): Routes{ let x: any = [ {path: '', redirectTo: 'welcome', pathMatch: 'full'}, {path: 'backend', loadChildren: 'app/backend/backend.module'} ] return x; } export const routes: Routes = routess(); export const

angular2 binding applies only after mouse movement

巧了我就是萌 提交于 2019-12-24 08:12:47
问题 I'm a new angular2 development and currently facing a rendering issue with my application. I use @angular@2.0.0-rc.1 for my app and router-deprecated@2.0.0-rc1 for my routing, whenever I click on the a link, the static content of the page loads immediately and the binding (dynamic content) happens only when I do some interaction with the mouse like click or hover over a link. I tried various options and still couldn't figure it out. Any help would be appreciated. 回答1: The order in which you

How to read $stateParms value in Angular2?

六眼飞鱼酱① 提交于 2019-12-24 07:59:19
问题 Using Ui-Router In Angular1 The stateparam value is coming using $state.params How to do the same thing in ANgular2 I tried like this this._uiRouter.globals.params.id it's working, But its not a proper solution, even I am using webstrome editor, the editor also showing error like TS2339 Property id does not exits on typeStateParams , Please help me do proper way 回答1: you can get state parameters from the Transition exportable object while configuring URL state: import {Transition} from "ui

Angular2, RouteParams not working

旧城冷巷雨未停 提交于 2019-12-24 06:38:27
问题 I'm getting a error that is currently causing lots of frustration. Here's what I running with: ASP.NET Core 1.0 RC1 Angular2, 2.0.0-beta.15 TypeScript, 1.7.6.0 The error(s): Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode. Attempting redirect to: /Design/0DEAC46A-7F58-49F9-B67E-2C187DFA49A7/ Navigated to http://localhost:5000/ EXCEPTION: Cannot resolve all parameters for 'RouteParams'(?). Make sure that all the parameters are decorated with