So I am using Laravel as a REST API and I want to use Angular for the front-end. However I wanted to use ui-router. However in the ui-view div it always render the index.php again. I think it is because the catch-all route but I can't fix it. Here is my code: Web routes:
Route::get('/', function () {
return view('index');
});
Route::get('/{any}', function ($any) {
return view('index');
})->where('any', '.*');
Here is my app.routes.js
(() => {
angular.module('estate-app')
.config(['$stateProvider', '$urlRouterProvider', ($stateProvider, $urlRouterProvider) => {
$stateProvider
.state('home', {
url: '/',
templateUrl: 'home/home.html',
controller: 'Home',
controllerAs: 'home'
});
$urlRouterProvider.otherwise('/');
}]);
})();
Has someone used ui-router with Laravel before? How did you integrate it? I get the same index.php in my ui-view div. I think it is because it can't find template url it catches it as a route and renders the index again. How can I fix it?