r/angularjs • u/[deleted] • Oct 11 '14
[General] Why should someone use angular.js?
I am new to RoR development and already making progress and building some wonderful apps. I've seen a lot of people using/talking about angular.js and I am really wondering what else can it do for an application. Can someone tell me an example please?
3
u/SleepyBrain Oct 11 '14
You should rephrase your question to "Why should someone use a front-end framework?"
Front-end devs figured out awhile ago that for performance, you can drastically reduce page load time by having the server only send data instead of html pages.
There are different front-end frameworks that work well with this idea, but to me angular makes the most 'sense.' I believe /u/calsosta gave a good list of features already, but honestly just try it and see if you like how it works.
1
Oct 11 '14
thanks a lot, I think I got it. TBH, I didn't know it was possible to do this. I feel like discovering America !
1
Oct 11 '14
I wonder If it's a lot of work to turn my views from RoR to Angular after developing an application.
1
u/torpedoshit Oct 12 '14
are both Angular and Bootstrap "front-end" frameworks? They seem so different, that it's strange to call Angular the same thing.
1
u/SleepyBrain Oct 12 '14
Bootstrap is more of a front-end library to help speed up development, while Angular is a framework that allows you to architect your front-end using a declarative approach.
Bootstrap does not provide structure to your app, and Angular doesn't not provide CSS, grids classes, or JavaScript components like tabs, modal, drop-down menus, etc. That's why it's easy to use them both together, since they both do different things.
6
u/kobescoresagain Oct 11 '14
Angular js makes the javascript and html on your page stay in sync. After you spend the time to understand it, it is extremely powerful.
4
u/calsosta Oct 11 '14
AngularJS follows an Model View Whatever style of separation, the result of using this properly is: less repetition and more code re-use, more structure and readability which gives you easier and cheaper maintainability and testing.
Practically speaking this will mean
UI (HTML) is completely separate from your business logic (Controller) - Now there is no confusion about where the code is or what it should do.
Common functionality like making AJAX calls can be abstracted to Services which makes it's reuse much easier
Only business logic is in the controller, that makes it easy to test at a unit level
Each application object can be given its own set of controllers, services, directives... for better organization
It forces you to design resulting in better quality
Using components from the community is often much clearer and simpler
Finally it has built in many functions to build a web application. These are things like the $http provider, it has routing (ng-route) to make a more native feeling app, it has a huge community of developers so chances are you can reuse a lot of code there. Tools like yeoman simplify the creation and structure of complex applications in Angular.
Bottom line, it will save you money and time allowing you to concentrate on delivering functionality rather than plumbing code.
1
u/Capaj Oct 11 '14
Any client side JS framework allows you to build your frontend and backend separately. That is great, because you reason about the development problems more easily. Compared to other JS frameworks angular allows you to write your frontend declaratively. Other frameworks allow you this too, but not as good as Angular. That is why you hear about Angular being so good.
1
u/TurboGranny Oct 11 '14
I think one of the best things about angular's MVC is using the these custom directives people have written that connect your models to other frameworks. Leaflet come to mind. Leaflet is a pretty sick map framework that you have to define every layer, label, marker, geojson, and path that you want on the map like you would normally expect or just loop through. With the custom directive someone wrote for it and angular's MVC approach, I can just point these data types at the model and it just goes. I can point the markers at a firebase or goinstant data store and now people can share instantly updating markers, and I didn't have to try at all. I can write code that changes the layers that are visible based on the zoom level without having to loop through removing and adding the items in those layers. I can have paths update based on the state of the markers or geojson with minimal code. It really is some awesome magic that frees up a lot of time spent in maintenance or dealing with the rising complexity issue you have in jQuery based applications.
-5
u/whooyeah Oct 11 '14
This is an annoying question like you see in the linkedin groups where lazy novice developers ask the most basic of questions repetitively. They don't even bother to search.
5 minutes of googling would have answered that question. There are hundreds of videos on yourtube answering that question.
If you want to be a good developer, teach yourself how to learn anything in quickly from google.
1
Oct 11 '14
It's very sad for the human race watching people spending 5 lines to scold someone when you can reply and explain in 1 sentence.
I could have spent more time searching (I've already did so) but I decided to ask here.. is that a crime ?
2
u/whooyeah Oct 11 '14 edited Oct 12 '14
I'm giving you the most useful advice your going to get.
Ask the hard questions.
Learn to teach yourself the easy stuff. like I said its all out there.
I work as a Lead Developer now completely self taught from free resources on the Internet.
here I'll help you out, I found these from the navigation at angularjs.org:
https://www.youtube.com/user/angularjs <- has a good introduction to angular video
Examples of angular projects: https://builtwith.angularjs.org/
1
u/johnnybravoh Oct 12 '14
The fact is that we stand on the shoulders of those before us.
"I work as a Lead Developer now completely self taught from free resources on the Internet." You have benefited from people taking the time to answer questions like the one posed. The tone and content of your response really annoys the shit out of me.
1
u/whooyeah Oct 12 '14 edited Oct 12 '14
No no no. I benefited by good documentation, well written blog posts and youtube videos.
What really annoys me is groups or forums becoming nurseries for lazy junior developers when they should be fostering development of those items I mentioned previously.
2
u/dr_theopolis Oct 11 '14
Troll.
Communities like this subreddit exist so we can help one another.
0
u/whooyeah Oct 11 '14
Come on man that sort of question should be answered in the side panel of the sub or the framework website.
0
Oct 11 '14
[deleted]
2
Oct 11 '14
Makes sense. Absolutely.
But what about the transactions in AJAX, meaning the calls ? Are they safe? Is it JSON just how angular communicates with RoR ?
So you're done with the Views of the framework (as Rails) ?
1
u/droidballoon Oct 11 '14
Your rails application would probably handle data through a REST API instead of putting the data into your rails templates. You would then only need one template that loaded up angular and your styles. Using JSON (or any other data format) is safe. You're still just sending text data just as you would when sending Rails templates rendered as HTML.
For added security you can still do authenticating and authorization on the rails side to ensure only the allowed clients gets their data.
3
u/[deleted] Oct 11 '14
If you're a RoR developer you should be very familiar with unit testing. Well, the biggest factor for me was that AngularJS makes unit testing very easy thanks to the separation of concerns it forces you to use (or at least heavily convinces you to use), compared to jQuery.