angular2-routing

Hash Location Strategy in Angular 2

若如初见. 提交于 2019-12-23 05:26:07
问题 I'm trying to create an application with hash location strategy, but it does not add the hash to the url. For instance when I click on a button associated with { path: '/polls', name: 'Polls', component: PollsComponent } it loads the page with this url : localhost:3000/polls. What do I have to change to get the hash location strategy? Why do I have to set the default base url if I want to use hash location strategy? This is the routing in the app.component.ts where all the routing is defined:

Angular 2: Displaying icons in navbar on authentication

五迷三道 提交于 2019-12-23 04:45:51
问题 My component structure looks roughly like this. My app component has a nav bar and router outlet. The nav bar has logo, some generic links and some specific links to be shown on user login and authentication only. The router outlet loads the home component or the wall component based on the routing url. The home component contains the login component which contains the customary user id, password and submit button. On submit, and upon successful login, the login component emits an event. Now,

How to redirect to next page by passing Id and show details in angular2

牧云@^-^@ 提交于 2019-12-23 04:26:41
问题 I have a json response like this. { "response": { "data": { "students": [{ "studentsNumber": "123", "studentsName": "ABC" }, { "studentsNumber": "345", "studentsName": "CDS" }] } } } I am doing a request to get the response data. I have a html where i am displaying list with the response data. My requirment is on click of each list item it should redirect to next html page.For that in the routerLink i am passing studentsNumber like this students.component.html <div *ngFor="let student of

Is there a way to preload routes in Angular 2 to prevent white flickering and jumping to top?

老子叫甜甜 提交于 2019-12-23 03:50:41
问题 Using the angular/angular2-seed I have defined a bunch of routes. However, I have the problem where each route is lazily loaded causing a white flickering and a delay (and jumps to the top of the page each first time a route is loaded)... the kind of thing we were getting away from when loading html files old style. Here is my route configuration: @RouteConfig([ {path: '/about', component: About, name: 'About', useAsDefault: true}, {path: '/features', component: Features, name: 'Features'},

How to do FULL SCREEN WINDOW functionality while clicking the button in Angular 2?

可紊 提交于 2019-12-23 03:31:47
问题 I have created the login page for the user. If They click the submit button, the page will navigate to one component (test.component.ts,test.component.html,..). I need to make that window in full screen mode. like, (video control full screen in html5). submitLogin() { if (this.userName === 'Student' && this.passWord === 'student@123'){ this.dashboard = true; } else { alert('Incorrect Username or Password'); } } I don't know how to achieve the full screen window functionality. Because, i am

Angular 5 child routes adding parentheses to the route

你说的曾经没有我的故事 提交于 2019-12-23 03:15:39
问题 I have an Angular 5 application with a series of components. Some of the components are children of others, and some are not. I would like the application to have a structure such as: */my-account/overview // homepage */my-account/my-stuff */profile */non-default I have a DefaultComponent that contains some generic elements such as site navigation that I would like to be present on most of the pages (everything except for the */non-default route/component). My routing module defines the

Angular: Some routes use PathLocationStrategy but some other routes use HashLocationStrategy

ぐ巨炮叔叔 提交于 2019-12-23 02:25:08
问题 I have 4 routes in my app.routes. import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; export const pageRoutes: Routes = [ {path: '', redirectTo: 'home', pathMatch: 'full'}, {path: 'home', component: HomeComponent}, {path: 'transaction', loadChildren: './app/transaction.module#TransactionModule'}, {path: 'evidence', loadChildren: './app/evidence.module#EvidenceModule'} ]; @NgModule({ imports: [RouterModule.forRoot(pageRoutes)], exports:

Angular 2/4/5 - Load child component to main router-outlet

时光毁灭记忆、已成空白 提交于 2019-12-23 02:21:39
问题 I am working with angular 5 currently. I have came across the problem with my router configuration and its presentation of component content accordingly. As below is my router configuration. const appRoutes: Routes = [ { path: "", pathMatch: "full", redirectTo: "home" }, { path: "home", component: HomeComponent }, { path: "applications", component: ApplicationsComponent, children: [{ path: ":applicationId/privacysettingsforapplications", component: PrivacysettingsforapplicationsComponent,

Expression wrapping in Angular/Typescript: Need explanation of Rule of thumb for when/where it's required

℡╲_俬逩灬. 提交于 2019-12-23 01:37:20
问题 In this code, can someone explain the rule of thumb for, why/when there is a need for, what I believe is called, expression wrapping within Typescript? i.e. the '(' ')' in <[Parent, (Children[])]> . If I defined a tuple type for example and used that in the resolve implements/method signature of the main code, would you still need the '(' ')' wrapped around the array of Children? Are there other scenarios in Typescript/Angular where ' expression wrapping ' occurs too? Is the specific to

Angular 2 pass array to router queryString

杀马特。学长 韩版系。学妹 提交于 2019-12-22 12:23:30
问题 I would like pass array ids: [1, 2, 3] to router query string like this: http://...some-url?ids=1&ids=2&ids=3 , but when I try to use const queryParams = { ids: [1, 2, 3] }; this.router.navigate(['/some-route'], { queryParams }); the result is http://...some-url/some-route?ids=1%2C2%2C3 Is there way to add query params with same key? 回答1: Looks like there is a bug in the router. Please, check this answer: https://stackoverflow.com/a/42505212/7634393 回答2: router.navigate is waiting for a named