// some.service.js
export default class SomeService {
constructor($http, $q) {
this.$http = $http;
this.$q = $q;
}
foo () {
return this.$q((resolve, reject) => {
// do something
});
}
}
// core.module.js
import someFactory from './some.factory.js';
import someService from './some.service.js';
import anotherService from './another.service.js';
angular
.module('app.core', [])
.factory({some: someFactory})
.service({
some: someService,
another: anotherService
})
;
function myVideoDirective() {
return {
restrict: 'E',
replace: true,
scope: {
videoId: '=?',
playlist: '=?',
loop: '=?',
mute: '=?',
start: '=?',
end: '=?',
contentZIndex: '=?',
allowClickEvents: '=?',
mobileImage: '=?',
playerCallback: '&?'
},
template: '<video-bg ratio="calcRatio()" <!-- перечисляем все атрибуты -->></video-bg> ,
link: function (scope, el, attr) {
scope.calcRatio = function () {
// тут что-то считаем, можем за чем-то следить...
}
// или можем считать еще где - в сервисе или в функции фабрике....
}
}
}