background preloader

Why does Angular.js rock?

Why does Angular.js rock?
Let’s see if we can discover why :) Angular.js is a MV* (Model – View – Whatever) Javascript framework which is maintained by Google which excels in the creation of single-page-applications or even for adding some “magic” to our classic web applications. I could spend all the day writing about why you should try Angular.js in your new project, but I feel that it would be better if we see it in action. Data binding and scopes The first question that usually comes to mind is: Does it support data binding? Let’s see an example of Angular.js’ way of data binding: In this little piece of code, there are a few things to explain but before that, I want you to get familiarized with the code: Try it Insert your name: Echo: NOTE: Don’t worry too much about the ng-app thing at this moment. As you see, what we write in the input, is echoed after it. Ok, but where are we saving that user.name? Alright alright, that wasn’t hard, but…. The idea is something like: Let’s see a complex example: See it Hello, World Related:  AngularJSangularJS

Deal with users authentication in an AngularJS web app This post is meant to share some thought about the main issues related to the user’s authentication in an AngularJS web app. This post is about how to maintain, and recognize, the status of authentication of an user (that is, if he’s logged in, or not) between the different routes of a web application. Moreover it also explains how to handle the case of a not authenticated user, who is trying to access to a page, that requires the user to be logged in. Before going into the details of my approach, it is very important to clarify that, because the user has full controll of the browser, each control implemented with front end technologies, must (!) be repeated also in the backend. Recognize an authenticated user There are probably several ways to recognize an authenticated user; infact it’s possible to set a global variable, or create a cookie… but my favourite way to reach the objective is to use an AngularJS service. Are you wondering about how to use this service?

AngularJS Best Practices - Jaco Pretorius Miško Hevery – the father of AngularJS – gave a very interesting presentation on AngularJS best practices in December of last year. This presentation is available on YouTube and the actual slides are on Google Docs. I’m going to cover a few of the points he covered in his presentation and give my take on them. Directory Structure Angular suggests that you use a certain directory structure, which you can create either using the Angular-seed project or the new Yeoman tool. This is called ‘Convention over Configuration’ – a concept you will hear a lot if you delve into Rails – although this doesn’t really apply in Angular as far as I can tell. In any case, it’s still a good idea to stick to the conventions simply to make it easier for a developer to look at your codebase and know where files should live. Everything that gets deployed is in the app directoryEverything outside of the app directory is for development Dependency Injection Hiding Flashes of Unstyled Content {{ interpolation }} More

SideWaffle Template Pack for Visual Studio witoldsz/angular-http-auth angularjs - What is the best practice for making an AJAX call in Angular.js Service, factory et provider dans AngularJS AngularJS est un framework difficile à prendre en main. Pas parce qu’il est particulièrement compliqué, mais parce que ses concepts sont vraiment différents de ceux qu’on a l’habitude de rencontrer dans les frameworks habituels. Le pire, c’est quand on vient de jQuery, car Angular est un peu l’anti-jQuery et il faut littéralement désapprendre ses habitudes. Généralement, les gens s’en sortent avec les contrôleurs. Par contre le côté service/factory/provider, ça c’est un gros problème. Article long = musique, évidement. On m’a très justement demandé les prérequis pour suivre cet article : il faut avoir fait des tutos de base sur Angular et notamment comprendre l’injection de dépendance et le data binding. Que font ces trucs là ? Techniquement, un service, une factory ou un provider, dans AngularJS, ça sert à la même chose. Les 3 servent à créer un objet Javascript ordinaire, c’est tout. Oui, oui, c’est vraiment tout. Et c’est tout. Créer un objet via un service/factory/provider C’est tout.

meliaxford/angular-client-side-auth angularjs - Angular - Best practice to structure modules Index Loading... A great way to get introduced to AngularJS is to work through this tutorial, which walks you through the construction of an AngularJS web app. The app you will build is a catalog that displays a list of Android devices, lets you filter the list to see only devices that interest you, and then view details for any device. Follow the tutorial to see how AngularJS makes browsers smarter — without the use of native extensions or plug-ins: See examples of how to use client-side data binding to build dynamic views of data that change immediately in response to user actions.See how AngularJS keeps your views in sync with your data without the need for DOM manipulation.Learn a better, easier way to test your web apps, with Karma and Protractor.Learn how to use dependency injection and services to make common web tasks, such as getting data into your app, easier. When you finish the tutorial you will be able to: Install Git You can download and install Git from

angular-app/angular-app Structuring an Angular Project We can build amazing SPA and HTML5 applications when choosing a powerful framework like Angular, Durandal, Ember, or Backbone. And while I love my personal favorites Angular and Durandal, it’s not all magic. There is a learning curve and some things are helpful to decide up front. Once you choose your presentation framework, you should decide how you will organize the structure of your project. UPDATE: Learn how you can refactor your Angular structure for growth in my “sequel” post. In this post I’ll show one way how I organize my Angular based projects and discuss why I like it. Before you ask “Why didn’t he mention Knockout.js? If you are interested in SPA, HTML5, Angular, BreezeJS or JavaScript patterns then you will love my upcoming course at Pluralsight, due out in September 2013. Sorting Boxes Most of my client code ends up in one of these 4 folders. /app/content/scripts/test App Code My app folder is where all of my files I wrote for my app reside. Controllers Services Directives Views

How To Use ngShow and ngHide Today we'll be looking at how we can use Angular's ngShow and ngHide directives to do exactly what the directives sound like they do, show and hide! What They Do ngShow and ngHide allow us to display or hide different elements. This helps when creating Angular apps since our single page applications will most likely have many moving parts that come and go as the state of our application changes. The great part about these directives is that we don't have to do any of the showing or hiding ourselves with CSS or JavaScript. It is all handled by good old Angular. Usage To use either ngShow or ngHide, just add the directive to the element you'd like to show or hide. <div ng-show="hello">this is a welcome message</div><div ng-show="! Once we have that set in our markup, we can set the hello or goodbye variables a number of different ways. All of the above can be used for ng-show or ng-hide. Using For Boolean Values See the Pen How To Use ngShow and ngHide by Chris Sevilleja (@sevilayha) on CodePen.

Authentication in AngularJS (or similar) based application. | Espeo Implementation of the concept described below and also a demo application is available here: Hello again, today I would like to write a little bit about how am I handling authentication in an application front-end running inside web browser, using AngularJS. Traditional server ‚login form’? At the beginning, I did not realize that traditional and commonly used form based authentication does not suit my client-side application. Let’s take a look at a sample server-side web application flow of events: Same application, but different flow: user asks for: something.com/secured/formXyz,server sends a login form,user logs in, fills a long and complicated form, but they are doing it so long that theirs session expires,user submits a form, but since the session is not valid anymore, login screen appears,once user logs in, server can process the submitted form, no need to re-enter everything again. OK, so let’s try other way around: Guess what?

Related: