angular-routing

Routing to a specific page within a lazy-loaded module in angular 2+

和自甴很熟 提交于 2019-12-11 02:29:48
问题 I have the following in my main app router: { path: 'users', loadChildren: 'app/modules/users/users.module#UsersModule', canLoad: [AuthGuard] } When the user goes to http://localhost:4200/users/1234 to see their profile, I try to save the full url (including the user ID above) so that I would route back to that page once they're logged in. The problem is, the Route parameter in the canLoad function only has a path field that does not include the user ID above, only the path users . Is there a

Angular 5 : How to get parent component routing parameter in child component?

大兔子大兔子 提交于 2019-12-11 02:26:27
问题 Here is add-new-folder.component , this component is child component of folder.component when I route on add-new-folder.component from folder.component that time I want folder.component parameter userid in its child component, I tried below code but i get console NaN how to get parent component parameter in child component kindly help me? add-new-folder.component.ts constructor(private route : ActivatedRoute,private router : Router){} ngOnInit() { this.route.parent.params.subscribe(params =>

Is Angular 2 Auxiliary router broken?

…衆ロ難τιáo~ 提交于 2019-12-11 02:02:06
问题 I'm trying to create an app with an auxiliary route for a chat window. The app fails right on the loading. It seems like a bug and I reported it on Angular GitHub, but I wonder if anyone knows a workaround? Here's the plunk of this simple app: http://plnkr.co/edit/JsZbuR @Component({ selector: 'basic-routing', template: ` <a [router-link]="['/Home']">Home</a> <a [router-link]="['/ProductDetail']">Product Details</a> <router-outlet></router-outlet> <router-outlet name="chat"></router-outlet>

How does Angular routing take precedence over file paths on a static site

拥有回忆 提交于 2019-12-11 01:27:43
问题 If I build a static site with the file structure: -index.html -blog/index.html And I put an Angular app with routing inside blog/index.html , then go to the route example.com/blog/page/2 , it goes to the correct blog page within the Angular application. In a sense, it opens /blog/index.html , and processes /page/2 within the Angular application. How? Why doesn't Apache (or Nginx) take precedence over that, and try to open /blog/page/2/index.html , and not finding it, show a 404? I think it's

Passing parent route params to child via service

夙愿已清 提交于 2019-12-11 00:55:22
问题 I am trying to pass route parameters from a parent component to child component using the method that the Angular team currently recommends: https://angular.io/docs/ts/latest/cookbook/component-communication.html#!#bidirectional-service The parent is able to successfully subscribe to the service which does emit correctly. However, the child does not receive anything when the page is loaded. Service @Injectable() export class AbcService { public paramSource: Subject<any> = new Subject<any>();

Angular-ui-router child state with multiple parent states

☆樱花仙子☆ 提交于 2019-12-11 00:08:24
问题 Using Angular-ui-router , is there a possibility to define a child-state that has multiple parent states : $stateProvider .state("parent1", { url: '/', templateUrl: 'parent1.html' }) .state('parent2', { url: '/parent2', templateUrl: 'parent2.html' }) //Make accessible from every state parent-state .state("child", { url: 'child', //TODO parents: ['parent1', 'parent2'] onEnter: function() { //do something; } }) Example : Your Angular app has a directive that is used multiple times in different

Angular Views/Routes in IE8

寵の児 提交于 2019-12-10 23:13:19
问题 I followed this document: http://docs.angularjs.org/guide/ie But still I do not see the views in IE8. It works fine in modern browsers. Does ngRoute helper module support IE8? Any suggestions? <!DOCTYPE html> <html xmlns:ng="http://angularjs.org" id="ng-app" ng-app="demoApp"> <head> <!--[if lte IE 8]> <script src="//cdnjs.cloudflare.com/ajax/libs/json3/3.3.0/json3.min.js"></script> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> </head> <body> <div

check if a route exist in angular 2

*爱你&永不变心* 提交于 2019-12-10 22:16:38
问题 I want to check if a route exists in an angular project. For example user types http://localhost:4200/#/timestamp in the url bar and timestamp does not exist in the project, how will you be able to check without redirecting? 回答1: There is no way to check if the route path exists in the config, however you can do a redirect in configuration using ** in router config module. export const AppRoutes = [ { path: "", redirectTo: "home", pathMatch: "full" }, { path: '**', redirectTo: 'home'} ]; Or

Angular Dart: matching rules for route path - implicit suffix wildcard?

限于喜欢 提交于 2019-12-10 21:56:04
问题 Consider (excerpt from the AngularDart tutorial): router.root ..addRoute( name: 'add', path: '/add', enter: view('view/addRecipe.html')) How is a URL matched with such a path? Is there an implicit wildcard suffix like /add/* or maybe /add* ? If so, how can I make /add match exactly /add to avoid conflicts with, say, /address ? 回答1: Correct, UrlTemplate does a naive prefix match, so /add will match /address . If you are worried about conflicts between two routes where path of one happens to be

How to not apply [routerLink] on a child element?

大城市里の小女人 提交于 2019-12-10 20:28:02
问题 I want to make a child element to trigger it own click even , and don't respond to it parent element having [routerLink], the problem is the child element can't run it delete() function in (click)="delete()" it just follow it parent in [routerLink] (it navigate to /product/:id) <div class="item"> <!-- parent element --> <a [routerLink]="['/product/'+product.id]"> <div class="figure"> <div class="sides"> <div class="side"> <div class="card"> <img class="img" [src]="product.thumb"> <div class=