Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70860

DI keeps injecting empty object?

$
0
0

@rastographics wrote:

I have a service:

import {Injectable} from '@angular/core';
import {Subject} from "rxjs";

@Injectable()
export class AuthTracker {
  public loginNotifier: Subject<boolean>;
}

When I import into my component, the authTracker param is just an empty object (no "loginNotifier" property):

import {NavController} from "ionic-angular";
import {AuthTracker} from '../../providers/authentication/auth-tracker';
import {Injectable, Component} from "@angular/core";
import {LoginPage} from "./login";
import {HelloIonicPage} from "../../pages/hello-ionic/hello-ionic";

@Component({
  template: ''
})
export class DispatchPage {
  constructor(nav: NavController, authTracker: AuthTracker) {
    let logsub = (loggedin) => {
      if (loggedin) {
        nav.setRoot(HelloIonicPage);
      } else {
        nav.setRoot(LoginPage);
      }
    };
    authTracker.loginNotifier.subscribe(logsub);
  }
}

I have the AuthTracker token provided in bootstrap:

ionicBootstrap(MyApp,[AuthTracker]);

No errors coming up. Please, what am I missing?

Posts: 2

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70860

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>