Angular(6)视图按钮(单击)功能重定向到Laravel(5.5)后端视图



当我单击"角前端"按钮重定向到Laravel后端视图时,我想要。我是Angular的新手。这就是我尝试做的。

frontend.component.html

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

frontend.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']);

homecontroller.php

public function index()
{
    return view('home');
}
userDetailsEdit() {
    window.location.href = 'http://localhost:8000/intro'; 
}

最新更新