Skip to content

FreshTouch/Angular2-navigate-with-data

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Angular2-navigate-with-data

Angular2+/4/5 - navigate with data

Install

npm install angular2-navigate-with-data -save

How to use

Initialize into app.module.ts

  import "angular2-navigate-with-data";

Example

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

class PageOne {
    constructor (
        private router: Router
    ){}
    
    public redirect()
    {
        this.router.navigateByData({
            url: ["/PageTwo"],
            data: [1,2,3,4,5], //data - <any> type
            //extras: {} - <NavigationExtras> type, optional parameter
        });
    }
}
import {Router} from '@angular/router';
import {OnInit} from "@angular/core";

class PageTwo implements OnInit {
    constructor (
        private router: Router
    ){}
    
    public ngOnInit()
    {
    	console.log(this.router.getNavigatedData()); //output [1,2,3,4,5]
    }
}

About

Angular2+/4/5 - navigate with data

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published