相关疑难解决方法(0)

Angular2:无法使用location.go(url)导航到url

我试图使用typescript函数中的location.go服务导航到特定的URL.它会更改浏览器中的URL,但URL的组件不会反映在屏幕中.它保留在登录(实际)屏幕上 - 例如:

constructor(location: Location, public _userdetails: userdetails){
    this.location = location;
}
login(){
    if (this.username && this.password){
        this._userdetails.username = this.username;
        this.location.go('/home');
    }
    else{
        console.log('Cannot be blank');
    }
}
Run Code Online (Sandbox Code Playgroud)

我缺少一个编译方法或刷新方法吗?

location angular2-routing angular

17
推荐指数
1
解决办法
3万
查看次数

标签 统计

angular ×1

angular2-routing ×1

location ×1