Why AngularJS services aren't available in configuration blocks

By : Akshar Raaj

This post explains why services aren't available in configuration blocks.

AngularJS has a concept of $injector which has a function called invoke().

AngularJS has two injectors. They are:

  • instanceInjector
  • providerInjector

When we say $injector, most of the times we mean instanceInjector. You can read more about injectors in our last post.

instanceInjector, or what we generally call $injector, can provide access to a service in either of the following ways:

  • instantiate the service. Once instantiated instanceInjector caches the service
  • get the service from cache if its alreay in cache

At low level, Controller or Service code is executed by ...

more info..

What, when and how of AngularJS configuration blocks

By : Akshar Raaj

Two blocks of modules run during bootstrap process. By bootstrap process we mean that they are run before any directive code or before any controller code. They essentially run before any developer written code. The two blocks are:

  • Configuration blocks
  • Run blocks

Configuration blocks are added by using .config() on module. Example:

angular
    .module("home")
    .config(function () {
    });

So the function which is passed to .config() is the configuration block.

Run blocks are added by using .run() on module. Example:

angular
    .module("home")
    .run(function () {
    });

In this post, we will try answering the following:

  • What is .config() and configuration block
  • When ...

more info..

AngularJS injectors internals

By : Akshar Raaj

In this post we will try to answer the following questions.

  • What is an injector?
  • What functionality does an injector provide?
  • Understanding different methods provided by injector.

What is an injector?

Injector is an object with some methods. It ensures that proper services are made available to the controllers by just using the name of the service.

Injector ensures that angular developers don't have to keep reference of services they create. Injector ensures that service references don't need to be passed around to every controller which needs services.

Assume you have a service in your app which is ...

more info..

How script ordering works in an Angular app

By : Akshar Raaj

In this post, we will understand how ordering of scripts of an angular application make difference to the app.

In any angular application, there will be a lot of controllers, services, directives etc. Controllers would be dependent on services. Several times I found that in index.html, service.js is put after controller.js and I wondered how is controller able to get access to service if service is included after controller. I had several other questions like:

  1. Do modules file need to be put before controllers?

  2. Do services need to be put before controllers?

  3. If services are put after ...

more info..

State pattern with UI Code

By : Akshar Raaj

This blog tells how I used state pattern in my UI code, and explains state pattern with JavaScript and jQuery.

Disclaimer:

  • This blog will not talk much about benefits of State pattern as there is already a lot written about it. It only gives a practical example of using state pattern with UI code.
  • I am not much confident about difference between State pattern and Strategy pattern. Let's discuss if I misunderstood State pattern.

Use case:

  • I have a page with two input fields.
  • Page initially has one title field and one body field.
  • There is a '+Add' button ...

more info..
Javed
Comments
Reactions

Real time applications with Django, XMPP and StropheJS

By : Javed Khan

TL;DR:

Introduction:

PubSub is a XMPP extension which allows publishing and subscribing to events. This is useful when you instantly want to notify many clients about something interesting happening on your server.

Quoting the authors of PubSub specs:

The protocol enables XMPP entities to create nodes (topics) at a
pubsub service and publish information at those nodes; an event
notification (with or without payload) is then broadcasted to all ...

more info..
© Agiliq, 2009-2012