Answer the question
In order to leave comments, you need to log in
Routing in laravel+angularjs?
I'm trying to make a bunch of laravel and angular.
And I see completely different routing methods - ngRoute and ui-routing. I can’t immediately understand what is what ...
the task is banal to make navigation without reloading the page ...
<ul class="nav navbar-nav">
<li><a href="/home">Home</a></li>
<li><a href="/sources">Sources</a></li>
</ul>
var myApp = angular.module('myApp', ['ngRoute','sourceCtrl', 'sourceService']);
myApp.config(['$routeProvider',
function($routeProvider) {
$routeProvider.
when('/sources', {
url: '/sources',
controller: 'sourceCtrl'
}).
when('/home', {
url: '/home',
controller: ''
}).
otherwise({
redirectTo: '/'
});
}]);
Answer the question
In order to leave comments, you need to log in
Forget about Laravel routing. Make the main page / in the Laravel routing, give the template, and then use the routing of the angular itself. Which one - decide for yourself. For API routes (Angular's call to the site itself, backend), select a subdomain or just make a group with a prefix.
Blade don't touch at all. Output a clean html code, and fill in the data itself with angular. If you really need some variables from pure Laravel, change the tags, there are plenty of instructions. You can also use {{}} under blade, and raw tags under angular - @{{}}. templateUrl - link to the template. Should be in the public folder. Actually, in order to display the template, there must be some element in the html itself, and the "ng-view" attribute is attached to it.
In general - the sea of guides. Type "laravel and angular app" into Google.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question