Angular ES6 wstrzykiwanie zależoności

0

Chciałbym z poziomu konstruktora w serwisie skorzystać ze $scope, $http etc.Projekt jest w ng.1.5 ale pisany komponentowo w ES6, kompilacja w webpack2. Wstrzykiwanie przez ngInject. Prosze o sugestie. Gdy pobieram przykładowo this.$http to dostaje undefined

export default class AuthenticationService {
    constructor(
        $rootScope,
        $http,
        $state,
        $scope,
        $timeout,
        $location
    ) {
        'ngInject';
        this.$http = $http;
        console.log( this.$http);
    } {
}

Poniżej screen po kompilacji:

screenshot-20170310192650.png

0

@Gutyo Z samym console.log($http) tez jest undefined

0

Pokaz deklaracje do angular.service

0

Ok, poniżej inicjalizacja servisu:


import AuthenticationService from '../services/authenticationService.service.js'

export default angular.module(
    'app.global',
    [
        uirouter
    ])
    .config(routing)
    .controller('appController', appController)
    .service('authenticationService', AuthenticationService)
    .component('navbar', {
        templateUrl: 'views/components/navbar/navbar.html',
        controller: NavbarController,
        bindings: {}
    })
    .name;

Całość jest wczytywana do components.js:

import globalapp from './client/global/index.js'
export default angular.module('app.components', [
  globalapp
])

i na koniec całość do app.js:

import Components from './components/components.js';
angular.module('app', [
    uirouter,
    Components.name,
]).config(routing);

1 użytkowników online, w tym zalogowanych: 0, gości: 1