$ npm install wtc-controller-element --save
ExecuteController is a static class used to register and instanciate controllers extended from the ElementController class.
Inside your module, BEFORE exporting it:
// Register
ExecuteControllers.registerController(TestController, '[Name]');
As a convention, please use the name as the same name of the controller.
There are 2 options, but first, import it:
import {ExecuteControllers} from 'wtc-controller-element';
This will instanciate all elements with a [data-controller] attribute.
ExecuteControllers.instanciateAll();
Just pass in the element and the name of the registered controller or the controller itself.
ExecuteControllers.instanciate(document.getElementById('id'), ['TestController'|TestController]);
ElementController is the base class for controllers that alter DOM elements. It's responsible for saving the state and the instance of the controller for easy reference.
Import and extend it in your module.
import {default as ElementController, ExecuteControllers} from 'wtc-controller-element';
class TestController extends ElementController {
constructor(element) {
super(element);
}
}
/* Don't forget to register it */
ExecuteControllers.registerController(TestController, 'TestController');
bower version is DEPRECATED and is here for older projects.
Please use the new ES6 module if possible.
bower install wtc-controller-element
Simply extend it on your controller function.