3

My application is getting appened inside another application and I cannot append anything in the url as parent application is restrict.

Is there a way I can stop appending in the url. I am able to do the same in angular2 alpha 34 build by this.router.navigate(value, true);

I want to do the same in @angular:2.0.1 and in the html not in my typescript class by defining a method and calling it on (click).

1
  • what does this mean My application is getting appened inside another application? Commented Oct 11, 2016 at 14:28

2 Answers 2

2

Sounds like you are looking for skipLocationChange:

router.navigate(['team', 33, 'user', 11], {relativeTo: route, skipLocationChange: true });

See also https://angular.io/docs/ts/latest/api/router/index/Router-class.html

Sign up to request clarification or add additional context in comments.

6 Comments

Is there a way I can do that from my html?
Don't think so. routerLink doesn't seem to provide an option.
What relativeTo: route does? without that option its working for me now. also cleaned it up little bit
Sorry, I just copied the code from the linked docs page. You only need to pass the route if you use relative paths from child routes.
@GünterZöchbauer Is it possible to apply for overall app instead of adding to each navigation?
|
2

skipLocationChange: true prevent angular2 to append anything in URL. As @Günter Zöchbauer suggested, You need to pass skipLocationChange: true as the default value is false.

full code will be:

import { Router }   from '@angular/router';

export class MovingInPages {

    constructor(private router: Router) {
    }

    moveToAnotherPage(value: string) {
        this.router.navigate([value], { skipLocationChange: true });
    }
}

The html will be like below:

<button type="button"  (click)="moveToAnotherPage('another-page-route')" class="btn btn-primary">Another page</button>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.