Alight declarative interface
Add declarative interface:
alight.namespace('ns')
.directive('name', {link})
.directives({
dirName: {link}
})
.controller(name, fn)
.controllers({
ctrlName(scope) {/*...*/}
});
// filters are the same
Namespace create alight new namespace or use existing. It is pretty and simple.
Extended example:
(function() {
'use strict';
alight.namespace('ns')
.controllers({userCtrl, settingsCtrl});
function userCtrl() {}
function settingsCtrl() {}
})();
Hi!
I don't very like this Angular 1 style, but I can add it to "ext" package. Also filters doesn't have namespace, controllers were removed, now direct-directives instead of them. Also filters and direct-directives can be located in scope, so you don't need always create namespaces, e.g.:
alight('body', {
data: '',
filter: (a, b) => a+b,
directive: () => {}
})
What is direct-directives? How to define it?
Declarative interface is about to avoid ugly constructions like alight.directives.ns = alight.directives.ns || {}; in modular applications.
And about namespaces itself. It very important to separate code into modules. Namespaces is the best trick to avoid conflicts. I have two different projects where I've realised toDate filters but they parsed different date formats which cause an error. This make me to rewrite one of the components.