I study ngdocs and start to implement it on my site, although I try my best to find a decent selection of examples to use as a guide. In particular, I used ES6 modules for my Angular build, and none of the examples cover this. My question is, what should be in the first place, “use strict” and import or the original ngdocs comment? Is there a strict rule on how these things need to be laid out?
I have compiled an example directive below, does it look normal? How can this be commented? I hope that I will understand this in detail as soon as I have done this, as soon as I hopefully go better. Thanks in advance.
'use strict';
import commentsController from './comments.controller';
import template from './comments.tpl.html!text';
function commentsDirective($compile, $templateCache) {
return {
restrict: 'E',
scope: true,
bindToController: true,
controllerAs: 'ctrl',
controller: commentsController,
template: template,
replace: true,
link: function(scope, element, attrs) {
function onClick(e){
return 'hello';
}
element.on('click', onClick);
}
};
}
commentsDirective.$inject = ['$compile', '$templateCache'];
export default commentsDirective;