salix/front/core/lib/section.js

35 lines
1.0 KiB
JavaScript
Raw Normal View History

import Component from './component';
/**
* Class with commonly injected services assigned as properties. It also has
* abbreviations for commonly used methods like tranlation.
*
* @property {Object} $translate Angular tranlation service
* @property {Object} $http Angular HTTP service
* @property {Object} $state Router state service
* @property {Object} $stateParams Router state parameters
*/
export default class Section extends Component {
constructor($element, $scope, $translate, $http, $state) {
super($element, $scope);
Object.assign(this, {
$translate,
$http,
$state,
$stateParams: $state.params
});
}
/**
* Translates an string.
*
* @param {String} string String to translate
* @param {Array} params Translate parameters
* @return {String} The translated string
*/
_(string, params) {
return this.$translate.instant(string, params, );
}
}
Section.$inject = ['$element', '$scope', '$translate', '$http', '$state'];