Skip to content
Rob edited this page Jan 23, 2015 · 5 revisions

With angular-next (and Angular 2.0) any class can be used as a service. In order to register it with Angular you just need to list it in your root component's componentServices.

Example

import {Component, TemplateConfig} from 'core/core.js';

class MyService1 {

}

class MyService2 {
    constructor(myService1: MyService1) {
        
    }
}

@Component({
    selector: 'my-comp',
    componentServices: [MyService1, MyService2],
    templateConfig: new TemplateConfig({
        inline: '<div>hello</div>'
    })

})
class MyComp {
    constructor(myservice2: MyService2) {
        ...
    }
}

Clone this wiki locally