My Existing code
<a class="getStart-button line blue" href="#" (click)="navigateBack()" title="Back">Back</a>
I want to use code without href like this:
<a class="getStart-button line blue" (click)="navigateBack()" title="Back">Back</a>
答案 0 :(得分:1)
好的,试试这个。
<a class="getStart-button line blue" (click)="navigateBack()" title="Back">Back</a>
在component.ts
import { Location, LocationStrategy, PathLocationStrategy } from '@angular/common';
@Component({
selector: 'selector',
providers: [Location, { provide: LocationStrategy, useClass: PathLocationStrategy }],
template: `your tempalte`
})
export class Component {
constructor(private location: Location) { }
public navigateBack(): void {
this.location.back();
}
}
在here中阅读更多角度定位服务。
希望这有帮助。