AngularJS Services Part 4: Value and Constant

So far we saw the magic of creating AngularJS services using Provider, Factory and Service. In this post, we will look at two more types of services - Value and Constant. Value The Value service is basically a service that returns a single value, like, string, object, number or an array. For instance: (function(){ angular.module('app', []) .value("Number", 24) .value("String", "Hey, how are you?") .value("Object", { prop1: 'prop1', prop2: 'prop2' }) ....

March 1, 2015 · 2 min · Ilija

AngularJS Services Part 3: Service

So, Service is basically the same as Factory, it just has one key difference. Service treats the function as a constructor, meaning, the service will call new on the function and return the resulting object as a service object. Oh, if you haven’t yet read about Factory, check out AngularJS Services Part 2: Factory. Using Service Declaring a Service is easy. Lets look at an example. (function(){ angular.module('app', []) .service("GreetingService", GreetingService); function GreetingService(){ this....

February 28, 2015 · 3 min · Ilija

AngularJS Services Part 2: Factory

If you don’t know the basics of AngularJS service, I recommend you read the other article I wrote on AngularJS Services Part 1: Provider. Provider v.s. Factory Factory is a thin wrapper on top of Provider. While Provider provides us the ability to configure the service provider before injection (creating the service object), Factory lacks that ability. Although it is short of this functionality, most of the Angular devs use factories because they are, in my opinion, the easiest to use and really cover all the general needs that one might need from a service....

February 27, 2015 · 3 min · Ilija

AngularJS Services Part 1: Provider

I started using AngularJS couple of months ago, when we got a new client that wanted us to help with building an app written in Angular. After couple of months of using it, I found myself struggling with uber-phat controllers and I started thinking of solutions about extracting knowledge out of the controller into separate entities. Also, having the ability to easily inject those entities back into the controller is a must....

February 25, 2015 · 6 min · Ilija

SOLID Principles in Ruby

Regardless of your knowledge level, as a programmer you love to write awesome code. It’s what we do. We like it and we do it every single day. But, we all know that writing awesome code is not easy at all. So, how can we improve the code we produce every day? An awareness (or a reminder!) of SOLID principles is beneficial here. SOLID is a group of five principles that when applied correctly can help us produce better code....

June 5, 2014 · 10 min · Ilija