LangComponent
import Loc from '../../../support/localization';
import StorageFactory from "../../../support/factories/storage.factory";
export default class LanguageComponent {
constructor(LanguageService) {
this.LanguageService = LanguageService;
this.storage = new StorageFactory();
this.langs = [];
this.LanguageService.all().then( (response) => {
storage.set('langs', response.data);
this.langs = response.data;
});
this.textLang = Loc.factory().get('panel').menu.t_language;
this.language = this.LanguageService.getLang();
this.template = `
<md-input-container style="margin-top: 20px !important; padding-bottom: 0">
<label style="color: white">{{::textLang}}</label>
<md-select ng-model="language" ng-change="onChangeLang()" aria-label="{{::textLang}}">
<md-option ng-repeat="lang in langs" value="{{lang}}">
{{lang}}
</md-option>
</md-select>
</md-input-container>
`;
}
static factory () {
return new this(...arguments);
}
link(scope, element, attrs) {
scope.onChangeLang = () => {
this.LanguageService.setLang(this.language);
}
}
}
LanguageComponent.factory.$inject = ['LanguageService'];
Ошибка
Cannot read property 'all' of undefined
Сгенерированый webpack`ом код
var LanguageComponent = function () {
function LanguageComponent(LanguageService) {
var _this = this;
_classCallCheck(this, LanguageComponent);
this.LanguageService = LanguageService;
this.storage = new _storage2.default();
this.langs = [];
this.LanguageService.all().then(function (response) {
storage.set('langs', response.data);
_this.langs = response.data;
});
this.textLang = _localization2.default.factory().get('panel').menu.t_language;
this.language = this.LanguageService.getLang();
this.template = '\n <md-input-container style="margin-top: 20px !important; padding-bottom: 0">\n <label style="color: white">{{::textLang}}</label>\n <md-select ng-model="language" ng-change="onChangeLang()" aria-label="{{::textLang}}">\n <md-option ng-repeat="lang in langs" value="{{lang}}">\n {{lang}}\n </md-option>\n </md-select>\n </md-input-container>\n ';
}
_createClass(LanguageComponent, [{
key: 'link',
value: function link(scope, element, attrs) {
var _this2 = this;
scope.onChangeLang = function () {
_this2.LanguageService.setLang(_this2.language);
};
}
}], [{
key: 'factory',
value: function factory() {
return new (Function.prototype.bind.apply(this, [null].concat(Array.prototype.slice.call(arguments))))();
}
}]);
return LanguageComponent;
}();
exports.default = LanguageComponent;
LanguageComponent.factory.$inject = ['LanguageService'];
Продвижение своими сайтами как стратегия роста и независимости