Luka's avatar
Level 1

Laravel 5 and Angular

I am just starting with my first project in Laravel. I normally use jQuery for all sort of Frontend Activity and AJAX, but I now thought that it would be a good idea to also learn a Frontend Framework. I am aware that Laravel has got Vue implemented, but there seems to be a higher demand for Angular knowledge, so I would like to use that. My first task is to create a dependable Dropdown, so I want to use a simple AJAX request to fill a dropdown from a database with Angular. At a later stage I want to create a file upload, but for now I just need to be able to do that simple task. My project is already up and running and its multiple pages with ACL/Auth etc, so I have to now install Angular in an existing project. Is all this possible? Anyone knows of an easy tutorial to do that normally simple task?

0 likes
7 replies
Luka's avatar
Level 1

Thank you. I have read many different tutorials, but to be honest I am still not clear about it how to do it. Lets say I already got my Laravel Blog Project in C:\xampp\htdocs\blog

If I understand right then I first need to run npm install -g @angular/cli ? Do I have to do it in that directory or do I have to create a Subfolder for it? And when I have done that, is Angular then installed for my Laravel Blog Website? Sorry for the stupid questions, but the tutorials I found are all rather confusing.

I just found the below tutorial, is this the right approach? http://www.codeinhouse.com/setup-and-integrate-angularjs-into-laravel/

Web Confection's avatar

@Luka VueJs can be used inline as part of a full stack solution. Angular is a decoupled solution, more SPA focused and best installed in a separate (sub)domain. If you are already using blade templates I would suggest sticking with Vue.

Luka's avatar
Level 1

Yes, I have read a few comments like that, but I am trying to widen my knowledge and I thought it would be a good idea to learn Laravel and Angular at the same time. Not sure this is the best idea indeed.

topvillas's avatar

If I were you, I wouldn't try and shoehorn Angular into a Laravel project. I'd create an API with Laravel and create a separate project with Angular.

Unlike Vue, I don't think Angular2+ was ever really designed to be used to provide simple client side functionality to single server rendered pages.

Luka's avatar
Level 1

Does make me wonder more and more if I should maybe stick to learn Laravel and Vue first. Specially since I am still not fully familiar how it all works with nodes, bower, sass etc.

I tried so much out with my first project that I wonder if all these files and folders are actually needed, so maybe I should start again with now Laravel 5.6 and get Bootstrap 4, jQuery and vue.js running...

Please or to participate in this conversation.