1.1.1 • Published 10 years ago
es6-angular-util v1.1.1
Installation
npm install --save es6-angular-utilUsage
Controller
The Controller class adds three utility methods for $watch, $emit and $on.
// foo.controller.js
import {Controller} from 'es6-angular-util'
export default class Foo extends Controller
{
constructor ($scope)
{
super($scope);
}
bar ()
{
this.emit(BAR);
}
}
export const BAR = 'Foo.BAR'Directive
The Directive class simplifies creating directives by passing the controller and template for assignment in the super class.
// foo.directive.js
import {Directive} from 'es6-angular-util'
import controller from './foo.controller'
import template from './foo.html'
export default class Foo extends Directive
{
constructor ()
{
super(controller, template)
}
}The third and fourth arguments allow you to specify scope variables and the controllerAs value:
// foo.directive.js
import {Directive} from 'es6-angular-util'
import controller from './foo.controller'
import template from './foo.html'
export default class Foo extends Directive
{
constructor ()
{
super(controller, template, {bar: '='}, 'baz')
}
}<!-- foo.html -->
{{baz.bar}}<!-- app.html -->
<foo bar="someBindableValue"></foo>