angular2-routing

Run a Service Function inside an Angular Routing Module class

依然范特西╮ 提交于 2019-11-29 18:15:38
So the basic story... At the top of this SPA is a 'top-bar' component, and inside that component is a search-bar component. Now - there are a few 'landing pages' where we want to turn this search-bar component off. I understand the process of using this through a service (since the 'landing pages' in question aren't directly connected to the search-bar component. And in and of itself - I had this working... The problem comes from the fact that if you land on one of these landing pages, and this search-bar gets turned off... If you leave the whole section and go to a different area that needs

Changing router-outlet with *ngIf in app.component.html in angular2

我的梦境 提交于 2019-11-29 17:20:52
问题 I am using angular 2.0 final. I am trying to change the location of the router-outlet in the main app.component.html. The template is updating fine display wise except, the first time I use router.navigate the component won't display in the new router-outlet, and there is no error. The second and every time after I use router.navigate it works properly. example template of app.component.html <div *ngIf="authenticated() == false"> <h1>not logged in</h1> <router-outlet> </router-outlet> </div>

Unhandled Promise rejection: Cannot match any routes

跟風遠走 提交于 2019-11-29 17:16:32
问题 When I run this unit test: it('can click profile link in template', () => { const landingPageLinkDe = linkDes[0]; const profileLinkDe = linkDes[1]; const aboutLinkDe = linkDes[2]; const findLinkDe = linkDes[3]; const addLinkDe = linkDes[4]; const registerLinkDe = linkDes[5]; const landingPageLinkFull = links[0]; const profileLinkFull = links[1]; const aboutLinkFull = links[2]; const findLinkFull = links[3]; const addLinkFull = links[4]; const registerLinkFull = links[5]; navFixture

Uncaught (in promise): TypeError: Cannot read property 'component' of null

半世苍凉 提交于 2019-11-29 16:30:07
问题 Getting this error when trying to use nestet route in Angular 4: ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'component' of null TypeError: Cannot read property 'component' of null at PreActivation.webpackJsonp.../../../router/@angular/router.es5.js.PreActivation.traverseRoutes (http://localhost:4200/vendor.bundle.js:77976:71) at http://localhost:4200/vendor.bundle.js:77954:19 at Array.forEach (native) at PreActivation.webpackJsonp.../../../router/@angular/router.es5

Angular 2 async pipe not rendering/updating Observable data automatically

喜欢而已 提交于 2019-11-29 15:54:31
I am facing an issue with the Angular2 router and an async pipe. I am trying to render an RxJs Observable and the data does not render automatically. One has to click on the link for the route for the data to render. Here is the root app: import {bootstrap} from 'angular2/platform/browser'; import {HTTP_PROVIDERS} from 'angular2/http'; import {ROUTER_PROVIDERS} from 'angular2/router'; import {AppComponent} from './app.component.ts'; bootstrap(AppComponent, [HTTP_PROVIDERS, ROUTER_PROVIDERS]); Here is the root component: import {Component} from 'angular2/core'; import {RouteConfig, ROUTER

how to apply different animation between different route in angular 2

走远了吗. 提交于 2019-11-29 15:33:23
I have a test app build with angular 2, I have successfully applied one animation between route change state('default', style({ opacity: 1, transform: 'scale(1) translateY(0)' })), transition('void <=> default', [ style({ opacity: 0, transform: 'scale(.9) translateY(-20px)' }), animate('.2s') ]) But I also want a different animation when a list page change to an item page, like click a hero inside a hero-list, so I did this state('childActivate', style({ opacity: 1, transform: 'scale(1) translateY(0)' })), transition('childActivate => void', [ animate('1.2s', style({ transform: 'scale(0.9)

Angular router '**' wildcard as a catch-all with child routes? Using latest 2.4.0 and Router 3.4.1

萝らか妹 提交于 2019-11-29 14:34:21
问题 I've been experimenting with dozens of configurations trying to get this to work but cannot figure this out. Given url as follows: https://domain.com Dashboard https://domain.com/profile Profile https://domain.com/anything ...catch all with children. https://domain.com/anything/edit https://domain.com/otherthing https://domain.com/otherthing/edit anything and otherthing can literally be anything. A route configuration I hoped would work but ends up taking over the defined routes where https:/

Error: (SystemJS) Can't resolve all parameters for ActivatedRoute: (?, ?, ?, ?, ?, ?, ?, ?)

[亡魂溺海] 提交于 2019-11-29 13:29:31
I'm trying to inject ActivatedRoute component into my component to access the ID of the object I'm editing (or to find out, there's no ID param, new object is created). I've created only the template for the component, and when I load start page (not event the page with the component I want to use) I get the following error: Error: (SystemJS) Can't resolve all parameters for ActivatedRoute: (?, ?, ?, ?, ?, ?, ?, ?). This is my code: import { Component, OnInit } from '@angular/core'; import { ActivatedRoute} from "@angular/router"; @Component({ selector: 'my-edit', templateUrl: './templates/my

No provider for ActivatedRoute - Angular 2 RC5

偶尔善良 提交于 2019-11-29 13:10:50
After upgrading to Angular 2 RC5 (from RC4) it seems I can no longer inject ActivatedRoute into my components. ORIGINAL EXCEPTION: No provider for ActivatedRoute! Here's the relevant piece of code: import { Component } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; declare var module: { id: string; }; @Component({ moduleId: module.id, selector: 'mds-app', templateUrl: 'app.component.html', styleUrls: [ 'app.component.css' ], directives: [] }) export class AppComponent { constructor(private _route: ActivatedRoute) { this._route.params.subscribe(params => console.log(

Angular 2 lazily loaded routes that contain aux router outlet

╄→гoц情女王★ 提交于 2019-11-29 12:42:42
I'm having an issue with my routing that I'd need a little help with. Originally I had all my routing in a single app.routing.ts file. I'm currently refactoring my routes into a files to accompany their corresponding feature modules to be lazily loaded. One lazily loaded feature module utilizes a secondary aux router outlet. Here is my code.... original : app.routing.ts const appRoutes: Routes = [ { path: 'settings', component: SettingsComponent, children: [ { path: '', redirectTo: '/settings/(settings:user)', pathMatch: 'full' }, { path: 'user', component: SettingsUserComponent, outlet: