angular-routing

Angular 4 Circular dependency detected

孤街浪徒 提交于 2019-11-28 07:17:11
Upgrading Angular Cli to 1.3.1 I have some warnings now WARNING in Circular dependency detected: src\app\work-sessions\work-session-list\work-session-list.routing.ts -> src\app\work-sessions\work-session-list\index.ts -> src\app\work -sessions\work-session-list\work-session-list.routing.ts Every class have a structure like this: work-session-list.routing.ts import { Route } from '@angular/router'; import { WorkSessionListComponent } from './index'; export const WorkSessionRoutes: Route[] = [ { path: '', component: WorkSessionListComponent }, ]; Index.ts export * from './work-session-list

Load controller dynamically based on route group

帅比萌擦擦* 提交于 2019-11-28 06:36:38
Is it possible to load a controller, it's js file, and a template dynamically based on a route group? Psuedo code which doesn't work: $routeProvider.when('/:plugin', function(plugin) { templateUrl: 'plugins/' + plugin + '/index.html', controller: plugin + 'Ctrl', resolve: { /* Load the JS file, from 'plugins/' + plugin + '/controller.js' */ } }); I've seen a lot of questions like this one but none that loads the js file/controller based on a route group. I managed to solve it inspired by @calebboyd, http://ify.io/lazy-loading-in-angularjs/ and http://weblogs.asp.net/dwahlin/archive/2013/05/22

Modify data object in ActivatedRoute

僤鯓⒐⒋嵵緔 提交于 2019-11-28 05:24:58
问题 I need to modify the breadcrumb value in the data object of my current route. Here is my route configuration. { path: "users", component: UserListComponent, children: [ { path: ":id", component: UserComponent, data: { breadcrumb: '<User name here>' }, } ], data: { breadcrumb: 'Users' } }, I am trying to do this: this._route.data = { breadcrumb: this.user.displayName }; //_route is ActivatedRoute but it doesn't work. Any help would be appreciated. Thanks. 回答1: The data property of a route is

Angular 2 Routing navigate run in new tab(Use Angular Router naviagte )

我怕爱的太早我们不能终老 提交于 2019-11-28 04:23:48
问题 How to open a new browser Tab , if using router.navigate . this.router.navigate([]).then(result => { window.location.href = link; }); 回答1: Try this one. this.router.navigate([]).then(result => { window.open(link, '_blank'); }); 回答2: currently i believe angular doesn't offer any method or service to do that so i've to use window object to open links in a new tab window.open(link, '_blank') 来源: https://stackoverflow.com/questions/50521494/angular-2-routing-navigate-run-in-new-tabuse-angular

What is the difference between ActivatedRoute and ActivatedRouteSnapshot in Angular4

痞子三分冷 提交于 2019-11-28 04:05:18
What is the difference between ActivatedRouteSnapshot and ActivatedRoute in Angular 4? It's my understanding that ActivatedRouteSnapshot is a child of ActivatedRoute , meaning that ActivatedRoute contains ActivatedRouteSnapshot . Incidentally, I tried running a Google search for an answer to this question, but I didn't find any of the search results to be understandable. Thank you! Since ActivatedRoute can be reused , ActivatedRouteSnapshot is an immutable object representing a particular version of ActivatedRoute . It exposes all the same properties as ActivatedRoute as plain values, while

Best method to set different layout for different pages in angular 4

谁说胖子不能爱 提交于 2019-11-28 03:04:09
I am new to angular 4. What I'm trying to achieve is to set different layout headers and footers for different pages in my app. I have three different cases: Login, register page (no header, no footer) routes: ['login','register'] Marketing site page (this is the root path and it has a header and footer, mostly these sections come before login) routes : ['','about','contact'] App logged in pages (I have a different header and footer in this section for all the app pages but this header and footer is different from the marketing site header and footer) routes : ['dashboard','profile'] I run the

Routing issue with AngularJS project using yeoman setup [duplicate]

筅森魡賤 提交于 2019-11-28 00:33:38
This question already has an answer here: AngularJS: How to remove #!/ (bang prefix) from URL? 6 answers I have setup a new Angular project using yeoman. Angular version is 1.6.0. Project setup was successful but I have been facing an issue with routing Task runner - Grunt When I run the project in local my local page will load with URL http://localhost:9000/#!/ I was expecting http://localhost:9000/#/ When clicked on About link browser is routed to http://localhost:9000/#!/%23%2Fabout Expectation: http://localhost:9000/#/about When I click home link browser is routed to http://localhost:9000/

How to get Route data into App Component in Angular 2

萝らか妹 提交于 2019-11-28 00:31:05
问题 I have defined some route data in my app routing module like below: const appRoutes:Routes = [ {path: '', component: LoginComponent, data:[{PageName:"Login Page"}]}] I want to get the data globally so that I can use appRoutes in app.component.ts to get the URL redirection related information as below: export class AppComponent { title = 'Welcome'; constructor(public router: Router, public authenticationService: AuthenticationService) { this.router.events.subscribe(event => { console.log("Url"

Auxiliary router-outlet inside primary router-outlet

家住魔仙堡 提交于 2019-11-27 22:29:36
问题 I'm trying to use an auxuliary router-outlet inside the primary router-outlet. app.routing export const appRoutes: Routes = [ { path: '', component: HomeComponent }, { path: 'page', loadChildren: () => new Promise(function (resolve) { (require as any).ensure([], function (require: any) { resolve(require('../pages/page.module').default); }); }) } ]; app.component @Component({ template: `<h1>My App!</h1> <a [routerLink]="['/page']">Page</a> <router-outlet></router-outlet>` }) page.module

How to use child routes in Angular 2

。_饼干妹妹 提交于 2019-11-27 21:23:36
Angular 2 version: 2.0.0-alpha.44 I've been trying to do routing in Angular 2. Though i was able to do the normal routing done, i am facing some issues when i introduce child routes. Here is the example on plnkr ( http://plnkr.co/edit/Y5doqU1WcEe4Ldr7KfPJ ) Below is the code for quick reference. I am trying to achieve below routing App /\ / \ HomeCmp HelloCmp \ \ ChildCmp And below is how i've configured my paths import {bootstrap, bind, Component, View} from 'angular2/angular2' import {RouteConfig, RouteParams, ROUTER_DIRECTIVES, APP_BASE_HREF, ROUTER_BINDINGS} from 'angular2/router'