Below is the custom directive implemented:
(function() {
angular.module('commentsDirective', [])
.directive('mngComments', mngComments)
function mngComments() {
return {
restrict: 'AE',
scope: { },
templateUrl: '/comments/comments.html',
controller: 'CommentsController',
controllerAs: 'vm',
bindToController: {
moment: '=',
comments: '=',
showComments: '='
}
};
};
})();
Usage of the directive and passing values:
<div mng-comments moment="vm.moments[0]" comments="vm.comments" showComments="true"></div>
There is a hard-coded "true" in showComments. However, in the comments.html file:
comments {{vm.showComments}}
The displayed value is {{vm.showComments}} without any assigned value. It simply shows 'comments'. vm.moments and vm.comments are being correctly passed.