Configuring a Provider

יום שלישי, פברואר 24, 2015

What is wrong with below code ? angular.module("MyApp", ).config(function (MyProvider) { }); angular.module("MyApp").provider("My", function () {     this.$get = function () {         var service = {             doSomething: function () {                 console.log("Do something ...");             }         };         return service;     } }); Nothing. But, depends on the version of Angular you are using you might encounter errors. Running above code with Angular 1.2.9 generates the following error: Failed to instantiate module MyApp due to unknown provider: MyProvider Apparently, Angular 1.2.9 queues config callbacks and provider registration requests into the same queue. Lets look at Angular 1.2.9 implementation for a module function module(name, requires, configFn) {         var invokeQueue = ;         var runBlocks = ;         var moduleInstance = {             provider: invokeLater('$provide', 'provider'),             config: invokeLater('$injector', 'invoke'),         };         return  moduleInstance;         function invokeLater(provider, method, im) {             return function() {                 invokeQueue();                 return moduleInstance;             };         }     }); }; A module instance holds two private queues, invokeQueue and runBlocks. Both provider and config methods are using invokeQueue queue Later, Angular loads the module by walking the queues and invoking all registered callbacks. Our problematic sample code first registers a config block angular.module("MyApp", ).config(function (MyProvider) { }); And only...
tags: , ,
no comments

Mobile Icons

יום שבת, פברואר 14, 2015

You know why I like Twitter's Bootstrap? Because of the Icon gallery I don't know what about you but for me it was always a challenge finding a nice icon gallery that fits my application needs. I used several commercial libraries but even then I found the supplied icon gallery to be quite limited Bootstrap has a nice icon gallery which are vector based (not pixel) which means you can enlarge each image and quality is kept. So, why am I telling you about it? Bootstrap is not new to anyone Well, I just found that they add additional images to their icon...
tags: , ,
no comments