当我单击"角前端"按钮重定向到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';
}