angular2-routing

Want to prevent Component recreation while routing in Angular 2

夙愿已清 提交于 2019-11-27 14:06:50
Let's say we have two routes Dashboard and Profile . Dashboard has dynamic tabs feature like Google spreadsheet . I want to do some interactions(build charts, visualizing some data) creating tabs in the Dashboard . Now, if I route to Profile and then route back to Dashboard , I want to see what was before in those tabs in Dashboard . It means, I want to maintain the state in the client side. AFAIK while routing between components, it recreates components. Is it possible to make spreadsheet like application while using angular 2 routing? I need to use routing because in my application I have to

PathLocationStrategy vs HashLocationStrategy in web apps

非 Y 不嫁゛ 提交于 2019-11-27 13:40:55
What are the pros and cons of using: PathLocationStrategy - the default "HTML 5 pushState" style. HashLocationStrategy - the "hash URL" style. for instance, using HashLocationStrategy will prevent the feature of scrolling to an element by its #ID, but some 3rd party plugins require the HashLocationStrategy or the Hashbang #! in order to work in ajax websites. I would like to know which one offers more for a webapp. Thierry Templier For me the main difference is that the PathLocationStrategy requires a configuration on the server side to all the paths configured in @RouteConfig to be redirected

Angular 2: Passing Data to Routes?

孤街浪徒 提交于 2019-11-27 13:28:17
I am working on this angular2 project in which I am using ROUTER_DIRECTIVES to navigate from one component to other. There are 2 components. i.e. PagesComponent & DesignerComponent . I want to navigate from PagesComponent to DesignerComponent. So far its routing correctly but I needed to pass page Object so designer can load that page object in itself. I tried using RouteParams But its getting page object undefined . below is my code: pages.component.ts import {Component, OnInit ,Input} from 'angular2/core'; import { GlobalObjectsService} from './../../shared/services/global/global.objects

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

谁说胖子不能爱 提交于 2019-11-27 13:21:22
问题 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

Share data between components using a service in Angular2

◇◆丶佛笑我妖孽 提交于 2019-11-27 13:15:10
I am developing an application using angular2. I have a scenario where I need to pass complex data (array of objects) from one component to another component(they are not parent-child, they are two separate components) while routing(using router.navigate()). I have googled this and most of the results describe the scenario of components that are parent-child. I have gone through the results and found these ways to pass the data. 1) Create Shared Service 2) Pass as route parameters 2nd approach works for me (even though, I don't like that when I have complex data as explained above). I am not

Angular2 Routing - keeping state of component when route changes [duplicate]

痴心易碎 提交于 2019-11-27 13:12:56
This question already has an answer here: Angular2 router 2.0.0 not reloading components when same url loaded with different parameters? 3 answers I have an application, with views behind routes, I need to be able to continue from the point when the route changed, but after going back, the component is in its initial state. Is there any way how to keep the state of a component? update 2 That's now fixed (Angular 2.3) for the new router by https://github.com/angular/angular/pull/13124 which allows to provide a custom reuse strategy. For an example see also https://www.softwarearchitekt.at/post

Angular 2 Hosted on IIS: HTTP Error 404

耗尽温柔 提交于 2019-11-27 13:08:53
问题 I have simple app with one component that expects certain parameters from url. there is only one route in the application: const appRoutes: Routes = path: 'hero/:userId/:languageId',component: HeroWidgetComponent }]; In the Index.html, I have this in the header <base href="/"> I am using webpack and the application runs fine on development environment, when browsing the url: http://localhost:4000/hero/1/1 . However, when building the app for production and getting the distribution files, then

How to get current route custom data in angular 2?

旧巷老猫 提交于 2019-11-27 13:04:52
问题 I have set up routes is like below const appRoutes: Routes = [ { path: 'login', component: LoginComponent, data: { title: 'Login TTX' } }, { path: 'list', component: ListingComponent, data: { title: ' TTX Home Page', module:'list' } }, { path: '', redirectTo: '/login', pathMatch: 'full' }, ]; now when i come to '/list' route then on 'listing.component.ts' i have written below code export class ListingComponent { public constructor(private router:Router) { //here how i can get **data** of *

How do I navigate to a sibling route?

▼魔方 西西 提交于 2019-11-27 12:17:32
Let's presume I got this router config export const EmployeeRoutes = [ { path: 'sales', component: SalesComponent }, { path: 'contacts', component: ContactsComponent } ]; and have navigated to the SalesComponent via this URL /department/7/employees/45/sales Now I'd like to go to contacts , but as I don't have all the parameters for an absolute route (e.g. the department ID, 7 in the above example) I'd prefer to get there using a relative link, e.g. [routerLink]="['../contacts']" or this.router.navigate('../contacts') which unfortunately doesn't work. There may be an obvious solution but I'm

Angular 2, RC5 router-outlet inside another router-outlet

拈花ヽ惹草 提交于 2019-11-27 11:47:15
问题 I'm trying to make one project with one router-outlet inside another router-outlet: It will work like this: In the first router-outlet it will have two views: auth component (/login) admin component (/admin) Then in the second outlet will be inside the admin component, with its own routes, that will render these: dashboard (/admin) profile (/admin/profile) users (/admin/users) Now, in the Angular 2 docs, I can see they have this implementation using modules. But I don't want to use multiple