angular2-routing

How to use the HashLocationStrategy with the Auth0 Lock widget for user login

泪湿孤枕 提交于 2019-12-28 03:03:06
问题 After updating the Auth0 login sample to use HashLocationStrategy in app.module.ts : import { LocationStrategy, HashLocationStrategy } from '@angular/common'; // (...) @NgModule({ providers: [ {provide: LocationStrategy, useClass: HashLocationStrategy}, appRoutingProviders, AUTH_PROVIDERS ], //(...) The Auth0 Lock authenticated event is not raised anymore: import { Injectable } from '@angular/core'; import { tokenNotExpired } from 'angular2-jwt'; // Avoid name not found warnings declare var

How to go back last page

旧街凉风 提交于 2019-12-27 10:20:48
问题 Is there a smart way to go back last page in Angular 2? Something like this._router.navigate(LASTPAGE); For example, page C has a Go Back button, Page A -> Page C, click it, back to page A. Page B -> Page C, click it, back to page B. Does router have this history information? 回答1: Actually you can take advantage of the built-in Location service, which owns a "Back" API. Here (in TypeScript): import {Component} from '@angular/core'; import {Location} from '@angular/common'; @Component({ //

Angular 2 nested module with own routes

家住魔仙堡 提交于 2019-12-25 16:53:39
问题 I have a project on Angular 2 that have this structure: ++ / --- app.module.ts +++ dashboard ---- dashboard.module.ts ---- dashboard.routes.ts ++++ adminarea ----- adminarea.module.ts ----- adminarea.routes.ts ++++++ user ------- usermanagement.component.html ------- usermanagement.component.ts ++++ home ++++ user So, on my app.module.ts i import dashboard.module.ts . On dashboard.module.ts i have the main route app. On dashboard.component.html i have <router-outlet></router-outlet> On this

MongoDB : Data not saving via Angular 2 services

这一生的挚爱 提交于 2019-12-25 11:14:11
问题 I have created routes and models as below and data seems to be saved from postman. UPDATE: Unable to save data after creating Angular services. I have created a service which will save the product data on click event. NODE JS CODE \var\www\html\Express\nodeauthapp-master\app.js const express = require('express'); const path = require('path'); const bodyParser = require('body-parser'); const cors = require('cors'); const passport = require('passport'); const mongoose = require('mongoose');

Angular2 refresh router-outlet

自古美人都是妖i 提交于 2019-12-25 09:19:47
问题 I'm working on a CRM and I have a select box in the header which allows the user to change the current user, In addition, the main content is inside the router-outlet. When the user select another user I want to refresh the page but only the router-outlet so the info will be for the new user I saw that other CRMs just redirect the user to the dashboard / index page, but I want to keep the user on the same page. 回答1: You should have a function in a service import {Subject} from 'rxjs/Subject';

Angular 2 Routing Refresh

别来无恙 提交于 2019-12-25 09:13:51
问题 I am trying to Implement Hashlocation Strategy out here it is not working please guide me. This is My Angular & Router Version Package.json "@angular/common": "2.0.0", "@angular/compiler": "2.0.0", "@angular/core": "2.0.0", "@angular/forms": "2.0.0", "@angular/http": "2.0.0", "@angular/platform-browser": "2.0.0", "@angular/platform-browser-dynamic": "2.0.0", "@angular/router": "3.0.0", "@angular/upgrade": "2.0.0", "bootstrap": "^3.3.6", Main.ts import { platformBrowserDynamic } from '@angular

RouterLink not working in grid in angular 2

送分小仙女□ 提交于 2019-12-25 08:59:29
问题 Recently i started using jqwidgets (here) for my Angular project, it worked well but the only problem is I put edit at each cell.To that edit button routerLink is not working. My code, this.columns = [ { text: 'Id', columntype: 'textbox', width: 80 }, { text: 'Name', columntype: 'textbox',datafield: 'name', width: 130 }, { text: 'Group Name', columntype: 'textbox', datafield: 'group_id', width: 130 }, { text: 'Actions',datafield: 'id', cellsrenderer: Action, width: 100 } ]; This is my action

Angular 2 how to define lazy loaded child routes of a parent route that's also lazy loaded

非 Y 不嫁゛ 提交于 2019-12-25 07:59:44
问题 I'm trying to get lazy loading to work for my app but it's one issue after another. I've gotten the main route to lazy load which is /admin , now I want to add another route which is /admin/login . So I did this: admin-router.module.ts @NgModule({ imports: [ ComponentsModule, SharedModule, RouterModule.forChild([ { path: '', component: AdminAreaComponent, children: [ { path: 'login', loadChildren: 'app/+admin-area/pages/login/login.module#LoginModule' } ] } ]) ], exports: [ RouterModule ],

angular2 router become undefined in subscribe method

倾然丶 夕夏残阳落幕 提交于 2019-12-25 07:41:13
问题 As the title explains it, the router object become undefined when it's called inside a subscribe member. Let me show you some code: export class AuthComponent implements OnInit { password = ''; email = ''; constructor( private _router: Router, private authService: AuthService ) { } sendLogin(): void { this.authService.login(this.email, this.password) .subscribe(function(token){ console.log("Success Response" + token) this.token = token // TOKEN Here is good // now I want to change my page,

How to provide a router navigate function in Angular 2 project

耗尽温柔 提交于 2019-12-25 07:26:28
问题 In my Angular 2 project I have a custom function goToObject(objectType:string, objectID: number) that I use to navigate to different objects throughout a couple of different components in my application. The function looks as follows: goToObject(objectType:string, objectID: number) { this._router.navigate([type, id]); } I was wondering if there is a way to provide this function throughout my complete project, without having to define it in each component separately. What makes it harder I