background preloader

Angular

Facebook Twitter

Flowjs/flow.js. Angular-cache. Angular-cache improves upon the capabilities of the $cacheFactory provided by AngularJS.

angular-cache

Project maintained by jmdobryHosted on GitHub Pages — Theme by mattgraham angular-cache (1.2.0) is a very useful replacement for Angular's $cacheFactory. Check out the demo for a quick introduction, or continue on down for more detailed information. The goal of the project is to solve a general problem, not satisfy a specific scenario. Quick Introduction View the Demo Mailing List $cacheFactory vs $angularCacheFactory Table of Contents Features Configuration Parameters storageMode Configure the cache to sync itself with localStorage or sessionStorage.

LocalStorageImpl and sessionStorageImpl When storageMode is set to "localStorage" or "sessionStorage" angular-cache will default to using the global localStorage and sessionStorage objects. 5 AngularJS Antipatterns & Pitfalls — nathan leclaire. AngularJS is a big JavaScript framework and it gives you just enough rope to hang yourself with.

5 AngularJS Antipatterns & Pitfalls — nathan leclaire

I’ve written a lot about it in this blog and really hope that I have made a noteworthy impact on improving the general availability of resources. I’ve been working on a project using AngularJS at my dayjob lately and noticed some antipatterns and pitfalls that people fall into when they are new to Angular (myself included, so they’re based on my own sweat and blood learning the framework) and I’ve consolidated some of them here for you to peruse.

Hopefully I’ll save you some pain. They are: Not having a dot in your ng-model (or other places you need it!) Angular’s directives provide fantastic flexibility and an amazing way to write HTML that describes its interactive behavior in a clean and clear fashion. In the above definition aProperty gets passed in through an attribute (normalized to a-property) and creates a two-way data binding between the parent scope and the child scope. AngularJS Routing Using UI-Router. Writing More Maintainable Angular.js Directives - The Code Dump. Directives are, essentially, the most powerful building blocks we have in Angular, yet for beginners they are incredibly easy to get messed up.

Writing More Maintainable Angular.js Directives - The Code Dump

Here are some guidelines that I’m pleased with, and that can help new comers. I would love any feedback from fellow coders! My assumptions: The main problems I have in maintaining “magical” code are lack of explicitness and traceability.

Unit Testing

4 Smooth AngularJS Application Tips — Nathan LeClaire. Anyone who follows my blog even a little closely can probably see that I <3 AngularJS: As I’ve learned more about the framework, I’ve come to appreciate many of the design decisions in spite of their initial (beastly) learning curve.

4 Smooth AngularJS Application Tips — Nathan LeClaire

For example, directives provide an absurd amount of flexibility and expressiveness in writing declarative HTML that is unmatched by jQuery-style imperative DOM twiddling. But the learning curve on them, and other bits of Angular, is weird: Hearkens to the Emacs graph of yore. Some things that should be pretty straightforward, like navigating from tab to tab in single-page web applications, can be a little confusing to cough up in code 100% GUARANTEED TO BE CORRECT ™. I touched on this a little bit in my unit testing article.

In the controller: In the view: Plunker demo of this concept: Very useful and IMO, very clean. Let’s say that you want to keep track of some data which multiple controllers can access. Cookies vs Tokens. Getting auth right with Angular.JS. Introduction There are basically two different ways of implementing server side authentication for apps with a frontend and an API: The most adopted one, is Cookie-Based Authentication (you can find an example here) that uses server side cookies to authenticate the user on every request.A newer approach, Token-Based Authentication, relies on a signed token that is sent to the server on each request.

Cookies vs Tokens. Getting auth right with Angular.JS

Token based vs. Cookie based The following diagram explains how both of these methods work. What are the benefits of using a token-based approach? Cross-domain / CORS: cookies + CORS don't play well across different domains. What's JSON Web Token? Asuming you have a node.js app, below you can find the components of this architecture. Server Side Let's start by installing express-jwt and jsonwebtoken: $ npm install express-jwt jsonwebtoken Configure the express middleware to protect every call to /api. The angular app will perform a POST through AJAX with the user's credentials: The Definitive Guide to Angular on Mobile. Mobile apps are not the next frontier for software developers, they’re already here.

The Definitive Guide to Angular on Mobile

There are already 1.2 billion mobile web app users and that number is growing rapidly (Wikipedia). Soon, the number of mobile devices will exceed the number of people on the planet. At the rate at which the number of mobile devices is growing, it’s estimated that 5.1 billion people will be using mobile phones by 2017. For us as app developers, it’s important that we develop for mobile technology if we want to stay relevant. With AngularJS, we have some great support for mobile, written by both the Angular team and the community.

In this article, we’re going to work through these two different ways to give our users a mobile experience for our app: Responsive web apps.