2
如何在没有路由的情况下监视和设置URL搜索参数?Angular2-没有路由的位置?
'地点',似乎有我想要的。不过,我得到这个错误:
Error: No provider for Location!
下列要求:
import { Component } from '@angular/core';
import { Location, HashLocationStrategy } from "@angular/common";
@Component({
selector: 'app-root',
templateUrl: 'app.component.html',
styleUrls: ['app.component.css'],
providers: [HashLocationStrategy]
})
export class AppComponent {
constructor(private location: Location){}
}
我怎么知道它想要哪个供应商?还有更好的方法来完成这个吗?
你可以分享你为什么不想从航线的帮助? –
您正在使用哪个版本的Angular2?位置被移到2.0.0-beta.16中常见https://github.com/angular/angular/blob/master/CHANGELOG.md#200-beta16-2016-04-26 – JayChase
@JayChase这是我的版本' m使用 – x0a