Archive: March 2013

Quickly experiment with AngularJS (and Jasmine) using these Plunks

Posted on by  
Emil van Galen

When experimenting with AngularJS features I often create a so-called Plunk on Although this site provides built-in templates for AngularJS, I found it useful to create my own since:

  • The “1.0.x (stable)” / “1.0.2 + Jasmine” templates use old versions of AngularJS;
  • “1.0.2 + Jasmine” template solely outputs Jasmine results but no AngularJS content.

Continue reading →

How to create (singleton) AngularJS services in 4 different ways

Posted on by  
Emil van Galen

Next to creating controllers and directives, AngularJS also supports “singleton” services. Services, like on the server-side, offer a great way for separating logic from your controllers. In AngularJS anything that’s either a primitive type, function or object can be a service. Although the concept of service is quite straight forward, the declaration of them in AngularJS isn’t:

  • There are 4 different ways to declare a service.
    • Registering a existing value as a service
    • Registering a factory function to create the singleton service instance
    • Registering a constructor function to create the singleton service instance
    • Registering a service factory which can be configured
  • Only 1 of them is extensively documented

Continue reading →

Grails Goodness: Set Property Values of Spring Beans in resources.groovy

Posted on by  
Hubert Klein Ikkink

We can configure Spring beans using several methods in Grails. We can for example add them to grails-app/conf/spring/resources.xml using Spring’s XML syntax. But we can also use a more Groovy way with grails-app/conf/spring/resources.groovy. We can use a DSL to define or configure Spring beans that we want to use in our Grails application. Grails uses BeanBuilder to parse the DSL and populate the Spring application context. To define a bean we use the following syntax beanName(BeanClass). If we want to set a property value for the bean we use a closure and in the closure we set the property values. Let’s first create a simple class we want to configure in the Spring application context:

// File: src/groovy/com/mrhaki/spring/Person.groovy
package com.mrhaki.spring

import groovy.transform.ToString

class Person {
    String name
    Date birthDate

Continue reading →