Authentication with AngularJS Managing authentication within your AngularJS application is extremely important, initially I found it quite difficult to find some examples of how to do it the right way for my startup keeping the logic clean, and as automated as possible. Initially I just rolled some convoluted solution using the $rootScope to store variables, and then access those variables within my controllers, but it was messy, and created a lot of duplicate code. So I was pointed to an article on the subject (thanks @gdi2290) that had a better example of how to do this, but it wasn’t setup for ui-router, so I had to adapt it a little to work with it. First of all I adjusted my routes to the following: (note the addition of the authenticate property) Then, within my run function, I’m listening to the $stateChangeStart event, which fires each time you move within your application. angular.module("myApp") .run(function ($rootScope, $state, AuthService) { $rootScope.
Google Maps for AngularJS ngDialog.js, native Angular.js Dialogs and Popups provider ngDialog.js is dialogs and popups provider for Angular.js applications. ngDialog.js is small (~2Kb), has minimalistic API, highly customizable through themes and has only Angular.js as dependency. Features With ngDialog you don’t need jQuery or Bootstrap to create dialogs for ng-app: Use it in controllers, factories or directivesCreate your own directivesStyle all UI and templatesConfigure themesAdd animations and effectsModule is shipped with both ngDialog service and default directive. 10 seconds get started Check it out
AngularUI for AngularJS Venturocket/angular-slider using angular service to share data between controllers Google's AngularJS Style Guide This is the external version of a document that was primarily written for Google engineers. It describes a recommended style for AngularJS apps that use Closure, as used internally at Google. Members of the broader AngularJS community should feel free to apply (or not apply) these recommendations, as relevant to their own use cases. This document describes style for AngularJS apps in google3. Style Note: Examples on the AngularJS external webpage, and many external apps, are written in a style that freely uses closures, favors functional inheritance, and does not often use JavaScript types. 1 Angular Language Rules 2 Angular Style Rules 3 Angular Tips, Tricks, and Best Practices 4 Best practices links and docs 1 Angular Language Rules Manage dependencies with Closure's goog.require and goog.provide Choose a namespace for your project, and use goog.provide and goog.require. goog.provide('hello.about.AboutCtrl'); goog.provide('hello.versions.Versions'); Why? Modules Why? For example: Why? Why? No:
Promises in AngularJS Promises are quite an old concept that took off only recently in the JavaScript world. Since version 1.2 promises have become such an important part of AngularJS that they cannot be overlooked anymore. In this post we will cover the basic concepts of promises in AngularJS with a few use cases at the end. So what are promises? The simplest definition of promises is given by the Promises/A+ specification: A promise represents the eventual result of an asynchronous operation. The two main functions performed by promises are: provide an interface for handling incomplete (asynchronous) operationserror handling for the said operations With a few nice extras derived from the above: chain asynchronous operations while avoiding callback hella syntax that loosely resembles the try catch finally construct Generic vs AngularJS implementation Promise instances can either be constructed by specialized factories (the case with Angular), or by static methods on the Promise object itself. The $http service
Box Elder Blog