background preloader

AngularJS

Facebook Twitter

Understanding AngularJS Dependency Injection – GeekHours. Dependency injection in AngularJS is supremely useful, and the key to making easily testable components.

Understanding AngularJS Dependency Injection – GeekHours

This article explains how Angular’s dependency injection system works. Dependency Injection is a software design pattern in which dependencies are injected into the components instead of hard coding them. This relieves a component from locating the dependency and makes dependencies configurable. This helps in making components reusable, maintainable and testable. Following are the core components which can be injected into each other as dependencies. ValueFactoryServiceProviderConstant The easiest way to remember the five components of dependency injection would be by memorizing the following sentence.

Value Value is a simple JavaScript object and it is used to pass values to controller during the config phase. Frequently Asked Questions · angular-ui/ui-router Wiki. Table of Contents: How Tos: How Tos are solutions to common problems.

Frequently Asked Questions · angular-ui/ui-router Wiki

They aren't necessarily the only solution to the problem but typically stemmed from a discussion in an issues thread, where we didn't want to add a new feature but realized it may not be clear how to achieve a certain functionality. Filtros personalizados en AngularJS - gerson.cl. En AngularJS, los filtros nos proporcionan una alternativa para formatear los datos usados por nuestra aplicación, o para desplegarlos a los usuarios.

Filtros personalizados en AngularJS - gerson.cl

AngularJS provee un conjunto de filtros listos para usar, y de manera adicional, nosotros podemos escribir los nuestros. En este artículo haremos lo segundo. Creación Para crear un filtro, simplemente lo agregamos a nuestro módulo, lo nombramos y retornamos los datos enviados inicialmente. Nota: Es una buena práctica crear un módulo para nuestros filtros distinto del módulo principal. angular.module('myApp').filter('slug', function() { return function(input) { if (input) { return input; } };}); Ok, nuestro filtro ya está recibiendo los datos, y retornándolos, pero no les está haciendo nada.

Angular.module('myApp').filter('slug', function() { return function(input) { if (input) { return input.toLowerCase().replace(/[^a-z_]/g, '_'); } };}); Utilización Ahora que tenemos este sencillo filtro, usémoslo. AngularJS ngAnimate: Tutorial - How to make Animations with AngularJS. The directive nganimate is very simple.

AngularJS ngAnimate: Tutorial - How to make Animations with AngularJS

You just need to declare the ng-animate attribute to an element that have another directive that changes the DOM. You can use the animations with the directives: And there are three ways to make animations in AngularJS: CSS3 Transitions CSS3 Animations Javascript I think that the CSS3 Transitions is the easiest way to do animation, but with the CSS3 Animations you can do much more complex animations. We will provite plunkers sample for a lot of cases, than you just need to change the css file to change the animation. AngularUI for AngularJS. GitHub - hrajchert/angular-screenfull: Angular binding to the Screenfull library to allow fullscreen in your app. AngularJS Noob to Master: the noob playlist - Lesson Playlist.

Interceptors in AngularJS and Useful Examples - WebDevEasy. The `$http` service of AngularJS allows us to communicate with a backend and make HTTP requests.

Interceptors in AngularJS and Useful Examples - WebDevEasy

There are cases where we want to capture every request and manipulate it before sending it to the server. Other times we would like to capture the response and process it before completing the call. Check condition before loading route in Angular JS. In this tutorial we will be using resolve of angular js routes to validate a condition and take action before loading the template into the view.Access control in single page angular applications which are using routes.

Check condition before loading route in Angular JS

To demonstrate this I’ll be building a simple app in this tutorial. I’ve provided the detailed explanation below but for people already knowing the working of routes in angular js here’s how you can use resolve in routes. Note:You can also use promise for this,resolve and reject that promise based on the condition. Checkout the demo: hereDownload the code:here There are cases some times when you want to only allow a user to a page/route only if some condition is satisfied. Most of the people end up writing the logic controller which ofcourse works but the user could see a flash of that inner page before he is redirected. Lets first have a look at our Code. GitHub - JoshSpears3/ngBoilerplate: Application starter kit for AngularJS Ready to use! AngularJS Form Validation. We have updated this article for Angular 1.3 and the new ng-touched feature.

AngularJS Form Validation

Today we’ll be looking at at the ways that Angular helps us do form validations. We’ll be talking more on forms using Angular (just like our other article: Submitting AJAX Forms: The AngularJS Way). Don’t worry though, that article is not required. We’ll focus on client side validation and using the built in Angular form properties. Here’s a quick demo. # Demo # Requirements Name is requiredUsername is not required, minimum length 3, maximum length 8Email is not required, but has to be a valid emailForm submit is disabled if the form isn’t validShow a required or invalid email errorAlert awesome if submitted correctly. Submitting AJAX Forms: The AngularJS Way. Erik August Johnson. If you are up on AngularJS 1.2+ then you might be aware that ng-bind-html-unsafe has been removed.

Erik August Johnson

The -unsafe directive was the simple (but unsafe) way to add HTML into your template. An example went something like: Iteration with ng-repeat was also straightforward: With the ng-bind-html directive however, there are several more steps involved. Here they are: 1. Var ExampleCtrl = function($scope) { } And in your HTML: