首页 > 解决方案 > Angular(6)视图按钮(点击)功能重定向到Laravel(5.5)后端视图

问题描述

我希望当我单击 Angular 前端按钮重定向到 Laravel 后端视图时。我是 angular 的新手。这是我尝试做的。请帮助我。

前端.component.html

<button type="button" (click)="userDetailsEdit()">Edit Details</button>

前端.component.ts

   userDetailsEdit() {
    alert('Its Working');
    this.authService.goToBreweryBarBackend();
}

auth.service.ts

 goToBreweryBarBackend() {
              const accessToken = JSON.parse(localStorage.getItem('access_token'));
              headers.append('Content-Type', 'application/json');
              this.http.get(this.url.LaravelURL + 'api/goToBreweryBarBackend', { headers: new Headers({ 'Authorization': 'Bearer ' + accessToken }) });

api.php

Route::get('/goToBreweryBarBackend', ['uses' => 'Homecontroller@index']);

家庭控制器.php

public function index()
{
    return view('home');
}

标签: angularlaravelredirectangular6backend

解决方案


userDetailsEdit() {
    window.location.href = 'http://localhost:8000/intro'; 
}

推荐阅读