navbar.directive.js
663 Bytes
(function() {
'use strict';
angular
.module('angular')
.directive('acmeNavbar', acmeNavbar);
/** @ngInject */
function acmeNavbar() {
var directive = {
restrict: 'E',
templateUrl: 'app/components/navbar/navbar.html',
scope: {
creationDate: '='
},
controller: NavbarController,
controllerAs: 'vm',
bindToController: true
};
return directive;
/** @ngInject */
function NavbarController(moment) {
var vm = this;
// "vm.creation" is avaible by directive option "bindToController: true"
vm.relativeDate = moment(vm.creationDate).fromNow();
}
}
})();