@Rabinzon

Как использовать $http в es6 классе?

export default class ThingFactory {
	constructor($http) {
		this.$http = $http;
		this.data = {
			name: "Name",
			age:  17
		};
	}
	get() {
		this.$http({
			method: 'GET',
			url: '/1'
		}).then(function successCallback(response) {
			console.log(response)
		}, function errorCallback(response) {
			console.log(response)
		});
	}
	newThing() {
		console.log('Getting a new Thing...');
		return this.data;
	}
}

Как заинжектить $http ?
  • Вопрос задан
  • 159 просмотров
Пригласить эксперта
Ответы на вопрос 1
@bromzh
Drugs-driven development
Подключаешь ngAnnotate и

export default class ThingFactory {
  // @ngInject
  constructor($http) {
  }
}
// ИЛИ
export default class ThingFactory {
  constructor($http) {
    "ngInject";
  }
}
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы