Laravel is a PHP Framework with lot of awesome features packed into it . You will never switch to any other framework if the requirements can be fulfilled by Laravel . We have covered some of topics related to Laravel . If you are new to Laravel we strongly recommend you to go through this tutorials
WHAT IS ANGULARJS
<button class="btn btn-success" type="submit" ng-click="doSomething()">Click here to call doSomething<button>
In AngularJS utility code can easily be separated as services and can be injected in controllers . Controllers encapsulates your application behaviour . It also provides two-way data binding , routing , animations ,templating ,dependency injection and testing is a breeze for AngularJS .
ANGULARJS WITH LARAVEL
I assume you have Laravel Installed . Go to AngularJS website and click on Download button you , here you can download latest stable build of AngularJS or directly link from CDN , I prefer CDN due to many reasons some of them are Better caching , Decreased Latency and Increased Parallelism . Create a new file index.php in views folder and paste below content .
Our html element have a ng-app attribute . Use this directive to auto-bootstrap an AngularJS application. The ngApp directive designates the root element of the application and is typically placed near the root element of the page – e.g. on the <body> or <html> tags. Only one AngularJS application can be auto-bootstrapped per HTML document .
ngView is a directive that complements the $route service by including the rendered template of the current route into the main layout (index.html) file. Every time the current route changes, the included view changes with it according to the configuration of the$route service.
In the above code we have created a module using angular.module and loaded ngRoute as dependency . In app.config we have injected routeProvider as dependency and used routeProvider to define two routes i.e / and /settings . When user navigates to / home.html will be loaded and HomeController will handle behaviour of our view . When user navigates to /settings then settings.html will be loaded and SettingsController will handle behaviour of our view . We have set <base href=”/”> in our view and using locationProvider html5mode as true which will below #/ from the URI . Try removing this lines and go to our view once you are done with Laravel Part .
Lets create our html files (home.html and settings.html) . Create a new folder in public/ and name it templates . Our html files are below .
<h1>This is home page</h1>
<h1>This is settings page</h1>
Now we are left with Laravel part . Our routes.php file looks something like this
return View::make('index'); // will return app/views/index.php
// CATCH ALL ROUTE =============================
//This will redirect all missing routes to AngularJS Framework .
If you have any problem with tutorial please comment below .