background preloader

Angular

Facebook Twitter

A Better Way to Learn AngularJS. Congratulations on taking the plunge!

A Better Way to Learn AngularJS

This AngularJS course is built with the intent of exposing you to the best available resources on each Angular topic. Our desire is to present these topics richly, and from a variety of vantage points, in order to afford you a more complete perspective on them. The learning curve of AngularJS can be described as a hockey stick. Initially getting off the ground with apps featuring basic functionality is delightfully easy.

However, when apps eventually grow large or complicated, structure without heed to Angular’s inner workings will cause development to become awkward and cumbersome. With AngularJS, the “Ready, Fire, Aim” learning methodology of duct taping together a handful of tutorials and a cursory glance through the documentation will lead to confusion and frustration. Since AngularJS is still in its infancy relative to other JavaScript frameworks, the number of encyclopaedic resources on it is still insufficient. DaftMonk/generator-angular-fullstack. How to Easily Validate Any Form Ever Using AngularJS.

If you’ve ever tried to build any kind of website, odds are you’ve had to create some way of validating and saving input from a form.

How to Easily Validate Any Form Ever Using AngularJS

Back in the bad old days this used to be a huge pain, because there were no good frameworks to help get the job done right. The three primary pain points that you have to deal with when trying to validate a form without the aid of a framework are: Pain Point #1. How to avoid writing a wall of if-statements for validating each data itemPain Point #2. How to handle adding and deleting data items as your code base evolves, i.e. how to avoid having to make changes in several different locations when you want to add/remove a data itemPain Point #3.

Thankfully there are now multiple frameworks available to help make the entire form process easier. The first Pain Point, avoiding writing a long list of ifs, is the easiest one to solve, and could hypothetically be fixed without the use of an existing framework. Every. Now the interesting part, list_view.jade. Ui-router/sample/states.js at gh-pages · angular-ui/ui-router. Recipes with Angular.js - Sharing Code Between Controllers using Services. Problem You wish to share business logic between controllers.

Recipes with Angular.js - Sharing Code Between Controllers using Services

Solution Utilise a Service to implement your business logic and use dependency injection to use this service in your controllers. The template shows access to a list of users from two controllers: The service and controller implementation in app.js implements a user service and the controllers set the scope initially: You can find the complete example on github. Discussion The factory method creates a singleton UserService, that returns two functions for retrieving all users and the first user only. Using dependency injection here is quite nice for testing your controllers, since you can easily inject a UserService stub. App.controller("AnotherCtrl", ["$scope", "UserService", function($scope, UserService) { $scope.firstUser = UserService.first(); }]); The syntax looks a bit funny, but since strings in arrays are not changed during the minification process it solves our problem.

Jacqueslareau/angular-pnotify. The Hitchhiker’s Guide to the Directive. AngularJS Directive is what we have close to Web Components at this time and is the most crucial and difficult piece in AngularJS.

The Hitchhiker’s Guide to the Directive

I’ve not found any suitable article on the web to fully understand directives behavior based on options it takes so I’m writing one. Fingers crossed! As you may know that directives can be used as an element, an atttribute, a class name, and a comment. Here are the ways we can use our directive angular in HTML: For a huge name such as this, you can split the words using hyphens while declaring and camel cased it while defining a directive. A Quick Demo to load AngularJS logo using the above directive. How Directive works? Blueprint? We’ll take a look at it briefly soon but meanwhile, here is the Directive definition: Now we’ll explore each option aforementioned one by one.

Compile function For an AngularJS newbie (including myself), its quite confusing to understand compile and link functions in the first place. Link function. AngularJS Promises - The Definitive Guide. Promises are a core feature of AngularJS - whether you understand them or not, if you use AngularJS you've almost certainly been using them for a while.

AngularJS Promises - The Definitive Guide

In this post I'm going to explain what promises are, how they work, where they're used and finally how to use them effectively. Once we've got the core understanding of promises, we'll look at some more advanced functionality - chaining and resolving promises when routing. Contents What are Promises? I'm going to try and be as succinct as possible - if anyone has a shorter, clearer description, let me know! A promise represents the eventual result of an operation. So let's see this in action. $http.get("/api/my/name"); This code uses the $http service to perform an HTTP GET on the url '/api/my/name'.

Now a common mistake for JavaScript newcomers might be to assume that the function returns the name: Authentication with AngularJS.