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