angular2-routing

Using cellRendererFramework in Angular 5 ag-grid data table

孤人 提交于 2019-12-06 06:24:46
问题 I am building a app in angular 5. In my HTML page, I have a table which shows the data on being queried. This data is being displayed in ag-grid using directive. One of the column in grid is displayed as HTML link. I am using cellRendererFramework feature to show the values in column as link. It is working fine and displays the link on the value for that column in table for each row. My requirement is that I want to pass additional parameter to cellRendererFramework component from the main

Angular2 App Routing through Services

给你一囗甜甜゛ 提交于 2019-12-06 05:23:54
Here's my scenario : Il get straight to the point first... I want to load all the routes including the default route of a app in RouteConfig through a service. I am able to do so but cannot load the default route dynamically, other routes can be loaded dynamically. Suppose i bootstrap(AppComponent) and my AppComponent view only content is <router-outlet></router-outlet> so in this scenario the AppComponent RouteConfig needs to be loaded dynamically i.e in my case i call a service which returns a JSON in this format [ { "path" : "/child1" , "name" : "Child1" , "component" : "ChildComponent1",

Cannot match any routes. URL Segment: '': When trying to use child routes and Ng2

旧巷老猫 提交于 2019-12-06 05:20:23
I have the following plunker , which does not work. In order to get it to work I can comment out... RouterModule.forRoot([ { path: "", component: TestComponent, children: [ // { // path:"", // outlet: "other", // component: TestComponent // } ] } ]) If I don't do that I get... EXCEPTION: Uncaught (in promise): Error: Cannot match any routes. URL Segment: '' Error: Cannot match any routes. URL Segment: '' How do I add a child route? You should give different path names until you use pathMatch: 'full' . Forked . More about the subject in Angular Router: Empty Paths, Componentless Routes, and

Angular2 router with Http data service through a Resolve with Observable catching 404

倾然丶 夕夏残阳落幕 提交于 2019-12-06 05:04:34
In my resolve guard I am getting an Http Observable to return the JSON of a user from a particular id . I want to catch an error and reroute to the users overview if the id does not exist. I have seen code that solves that with a Promise, but not with an Observable. I would like to see a solution with an Observable! Currently I get an "EXCEPTION: Uncaught (in promise): Response with status: 404 Not Found for URL: http://127.0.0.1:3000/users/191" since user 191 does not exsist. Here is my code: Resolve: import { Injectable } from '@angular/core'; import { Resolve, ActivatedRouteSnapshot,

Load nested routes in same router-outlet

…衆ロ難τιáo~ 提交于 2019-12-06 03:55:49
I have an Angular 4 application and my private.component.html something like this: <app-breadcrumb></app-breadcrumb> <router-outlet></router-outlet> And my routing: const privateRoutes: Routes = [ { path: '', component: PrivateComponent, children: [ { path: 'dashboard', component: DashboardComponent }, { path: 'settings', component: SettingsComponent }, { path: 'companies', component: CompaniesComponent, children: [ { path: 'add', component: FormCompanyComponent }, { path: ':id', component: CompanyComponent } ] } ] } ]; All components on first level is rendered in router-outlet of

Angular 2: Route parameter changes, reload the same page?

社会主义新天地 提交于 2019-12-06 02:20:41
问题 I have a route with a parameter, when going to the page /users/123 where 123 is the parameter the ngOnInit is called, I get my parameter and I call my method to get the user. However, when I'm on that page and I click a second link /users/456 then the ngOnInit is not called anymore (because that page is already instantiated). So without ngOnInit I can't get the route parameter and can't call my method to get the user. If I go to /users/123, then to /home, then to /users/456, it works

angular2 router.navigate inside auth0 callback

大城市里の小女人 提交于 2019-12-06 02:15:39
问题 I am having an issue rendering a template after calling router.navigate inside a callback for auth0lock loginComponent.ts import {Component, Inject} from 'angular2/core'; import {Router, ComponentInstruction} from 'angular2/router'; import {Auth} from '../auth'; declare var Auth0Lock; @Component({ selector: 'login', templateUrl: '/tpls/login/login.html' }) export class LoginComponent { private lock = new Auth0Lock('xxx', 'xxx.auth0.com'); constructor(@Inject(Router) private router: Router,

router.navigate changes the URL, but is not rendering the component

你。 提交于 2019-12-06 01:48:43
问题 Instead of using <a href="/my-path/{{my_param}}"></a> in my template, I am willing to use a function with paramters to redirect me to a page. So, this is how I built my function in my .ts file: redirectToChat(my_param){ this.router.navigate(['./my-path/' + my_param ]); } And how I called it in my template: <div (click)="redirectToChat(my_param)"> ... </div> It changes the URL, but not rendering the component. I imported this in my component: import { Router, ActivatedRoute, ParamMap } from '

angular 2 testing w/router

耗尽温柔 提交于 2019-12-06 01:08:28
I have a component and when a user logs in it routes to a url called /dashboard I am really struggling figuring out why I am getting the following error. cannot read property 'args' of undefined I have been following the official docs on testing with router found here https://angular.io/docs/ts/latest/guide/testing.html#!#routed-component but it doesnt seem to help. Half my problem is I dont quite understand all the code in the doc. Here is my unit test for the route beforeEach(async(()=>{ class AuthStub{ private loggedin: boolean = false; login(){ return this.loggedin = true; } }; class

Cannot read property 'filter' of null in angular 2?

谁说我不能喝 提交于 2019-12-06 00:36:43
问题 I am getting this error Cannot read property 'filter' of null when I apply filter in angular 2 .here is my code http://plnkr.co/edit/K46jJsnmHiONuqIsnuzW?p=preview import {Pipe} from 'angular2/core'; @Pipe({ name: 'sortByName', pure: false, }) export class SortByNamePipe { transform (value, [queryString]) { // console.log(value, queryString); return value.filter((student)=>new RegExp(queryString).test(student.name)) // return value; } } 回答1: It's because you have data as input that are loaded