在 angular2 中,我可以从哪里导入位置?我正在使用新库



在 angular2 中,我可以从哪里导入位置?我正在使用新库。

我尝试从这里获取它,但它不起作用:

import { Routes, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, Location} from '@angular/router';

我的app.component

import { Component } from '@angular/core';
import { Routes, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, Location} from '@angular/router';
import { HTTP_PROVIDERS, HTTP_BINDINGS} from '@angular/http';
import { NgIf } from '@angular/common';
import {Home} from './components/home/home';
import {Messages} from './components/messages/messages';
import {NewJobs} from './components/newJobs/newJobs';
import {NewJob} from './components/newJob/newJob';
import {Blog} from './components/blog/blog';
import {BlogArticle} from './components/blog/blogArticle';
import {CreateJob} from './components/createJob/createJob';
import {SearchJobs} from './components/searchJobs/searchJobs';
import {Login} from './components/login/login';
import {Applications} from './components/applications/applications';
import {Register} from './components/register/register';
import {ForgotPassword} from './components/forgotpassword/forgotpassword';
import {ChangePassword} from './components/changepassword/changepassword';
import {ChangeEmail} from './components/changeemail/changeemail';
import {SocialRegister} from './components/socialregister/socialregister';
import {Admin} from './components/admin/admin';
import {Contact} from './components/contact/contact';
import {SearchUsers} from './components/searchusers/searchusers';
import {Jobs} from './components/job/jobs';
import {CompanyProfile} from './components/company/company';
import {Dashboard} from './components/dashboard/dashboard';
import {Profile} from './components/profile/profile';
import {UserApplications} from './components/userApplications/userApplications';
import {Messenger} from './components/messenger/messenger';
import {Help} from './components/help/help';
import {Achievements} from './components/achievements/achievements';
import {Sitemap} from './components/sitemap/sitemap';
import {HeaderNavigation} from './components/header/header';
import {HeaderNavigationLoggedIn} from './components/header/headerNavigationLoggedIn';
import {HeaderNavigationLoggedInCompany} from './components/header/headerNavigationLoggedInCompany';
import {Footer} from './components/footer/footer';
import {SideMenuCompany} from './components/header/sideMenuCompany';
import {SideMenuUser} from './components/header/sideMenuUser';
import {Splash} from './components/splash/splash';
import {Environment} from './models/environment/environment';
import {UserProfile} from './models/profile/profile';
import {Organisation} from './models/organisation/organisation';
import {User} from './models/user/user';
import {AuthService} from './services/authService/authService';
import {SocialService} from './services/socialService/socialService';
import {UserService} from './services/userService/userService';
import {OrganisationService} from './services/organisationService/organisationService';
import {NotificationService} from './services/notificationService/notificationService';
import {ApplicationService} from './services/applicationService/applicationService';
import {JobService} from './services/jobService/jobService';
import {MessageService} from './services/messageService/messageService';
import {EmailService} from './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());
    })  
  }
}

您可以在官方文档中以最快的方式查找此内容。(至少您目前会在那里找到;)的进口)

看看这个链接,你会看到Location属于@angular/common包:

https://angular.io/docs/ts/latest/api/#!?apiFilter=location

当您单击位置的详细信息时,文档有点奇怪,因为除了在他们的示例中(您在参考中找不到任何地方)之外,那里没有提到@angular/common任何地方。

相关内容

  • 没有找到相关文章

最新更新