this question has answer here:
in angular2 can import location ? i'm using new libraries.
i tried getting here doesn't work:
import { routes, router_directives, router_providers, location} '@angular/router';
my app.component
:
import { component } '@angular/core'; import { routes, router_directives, router_providers, location} '@angular/router'; import { http_providers, http_bindings} '@angular/http'; import { ngif } '@angular/common'; import {home} './components/home/home'; import {messages} './components/messages/messages'; import {newjobs} './components/newjobs/newjobs'; import {newjob} './components/newjob/newjob'; import {blog} './components/blog/blog'; import {blogarticle} './components/blog/blogarticle'; import {createjob} './components/createjob/createjob'; import {searchjobs} './components/searchjobs/searchjobs'; import {login} './components/login/login'; import {applications} './components/applications/applications'; import {register} './components/register/register'; import {forgotpassword} './components/forgotpassword/forgotpassword'; import {changepassword} './components/changepassword/changepassword'; import {changeemail} './components/changeemail/changeemail'; import {socialregister} './components/socialregister/socialregister'; import {admin} './components/admin/admin'; import {contact} './components/contact/contact'; import {searchusers} './components/searchusers/searchusers'; import {jobs} './components/job/jobs'; import {companyprofile} './components/company/company'; import {dashboard} './components/dashboard/dashboard'; import {profile} './components/profile/profile'; import {userapplications} './components/userapplications/userapplications'; import {messenger} './components/messenger/messenger'; import {help} './components/help/help'; import {achievements} './components/achievements/achievements'; import {sitemap} './components/sitemap/sitemap'; import {headernavigation} './components/header/header'; import {headernavigationloggedin} './components/header/headernavigationloggedin'; import {headernavigationloggedincompany} './components/header/headernavigationloggedincompany'; import {footer} './components/footer/footer'; import {sidemenucompany} './components/header/sidemenucompany'; import {sidemenuuser} './components/header/sidemenuuser'; import {splash} './components/splash/splash'; import {environment} './models/environment/environment'; import {userprofile} './models/profile/profile'; import {organisation} './models/organisation/organisation'; import {user} './models/user/user'; import {authservice} './services/authservice/authservice'; import {socialservice} './services/socialservice/socialservice'; import {userservice} './services/userservice/userservice'; import {organisationservice} './services/organisationservice/organisationservice'; import {notificationservice} './services/notificationservice/notificationservice'; import {applicationservice} './services/applicationservice/applicationservice'; import {jobservice} './services/jobservice/jobservice'; import {messageservice} './services/messageservice/messageservice'; import {emailservice} './services/emailservice/emailservice'; @component({ moduleid: module.id, selector: 'app', providers: [router_providers, http_providers, userservice, userprofile, organisationservice, organisation, environment, http_bindings], template: ` <headernavigation></headernavigation> <router-outlet></router-outlet> `, directives: [router_directives, headernavigation] }) @routes([ { path: '/', component: home, as: 'home'}, { path: '/home', component: home, as: 'home', useasdefault: true}, { path: '/login', component: login, as: 'login' }, { path: '/register/', component: register, as: 'register' }, { path: '/register/:id', component: register, as: 'register' }, { path: '/forgotpassword', component: forgotpassword, as: 'forgotpassword' }, { path: '/dashboard', component: dashboard, as: 'dashboard' }, { path: '/search', component: searchjobs, as: 'search' }, { path: '/search/:id', component: searchjobs, as: 'searchjob' }, { path: '/profile', component: profile, as: 'profile' }, { path: '/settings', component: companyprofile, as: 'settings' }, { path: '/jobs', component: jobs, as: 'jobs' }, { path: '/password', component: changepassword, as: 'password' }, { path: '/email', component: changeemail, as: 'email' }, { path: '/applications/:id', component: applications, as: 'applications' }, { path: '/applications', component: applications, as: 'applications' }, { path: '/socialregister/:id', component: socialregister, as: 'socialregister' }, { path: '/socialregister', component: socialregister, as: 'socialregister' }, { path: '/applys', component: userapplications, as: 'applys' }, { path: '/contact', component: contact, as: 'contact' }, { path: '/searchteachers', component: searchusers, as: 'searchusers' }, { path: '/createjob', component: createjob, as: 'createjob' }, { path: '/pizzacat123', component: admin, as: 'pizzacat123' }, { path: '/messenger', component: messenger, as: 'messenger' }, { path: '/messenger/:id', component: messenger, as: 'messenger' }, { path: '/messenger/:id/:type/:roomid', component: messenger, as: 'messenger' }, { path: '/help', component: help, as: 'help' }, { path: '/achievements', component: achievements, as: 'achievements' }, { path: '/blog', component: blog, as: 'blog' }, { path: '/blog/:slug', component: blogarticle, as: 'blogarticle' }, { path: '/sitemap', component: sitemap, as: 'sitemap' }, { path: '/newjobs', component: newjobs, as: 'newjobs' }, { path: '/newjob/:slug', component: newjob, as: 'newjob' }, { path: '/messages', component: messages, as: 'messages' }, { path:'/**', redirectto: ['login']} ]) export class appcomponent { authservice: authservice; userservice: userservice isloggedin: boolean = false; iscompanylogin: boolean = false; isuserlogin: boolean = false; userprofile: userprofile; constructor(_authservice: authservice, _userservice: userservice, _userprofile: userprofile, private location: location){ this.authservice = _authservice; this.userservice = _userservice; this.userprofile = _userprofile; this.router.changes.subscribe((value) => { console.log(location.path()); }) } }
you can fastest way in official documentation. (at least imports find there @ moment ;))
take @ link, , you'll see location
belongs @angular/common
package:
https://angular.io/docs/ts/latest/api/#!?apifilter=location
the documentation bit weird @ point click on details of location because @angular/common
mentioned there, except in example (which won't find everywhere in reference).