ddomingues / angular2-devise-token-auth

Helper library for working with Devise Token Auth in your Angular 2 applications
5 stars 3 forks source link

Error with AUTH_PROVIDERS (Angular2+Ionic2) #1

Open hivemindunit opened 8 years ago

hivemindunit commented 8 years ago

Hi!

Tried to use this with Ionic2/Angular2 project. When running app in browser getting the next error: reflective_provider.js:163 Uncaught Invalid provider - only instances of Provider and Type are allowed, got: [object Object]

Here is my app.ts file:

import { Component, ViewChild } from '@angular/core';
import { AUTH_PROVIDERS, authService } from 'angular2-devise-token-auth';
import { HTTP_PROVIDERS } from '@angular/http';
import { App, ionicBootstrap, Platform, Nav } from 'ionic-angular';
import { StatusBar } from 'ionic-native';

...

@Component({
  templateUrl: 'build/app.html'
})
class MyApp {
  @ViewChild(Nav) nav: Nav;

  ...
  constructor(private platform: Platform) {
    this.initializeApp();
    ...
  }

  initializeApp() {
    ...
  }
}

ionicBootstrap(MyApp, [HTTP_PROVIDERS, AUTH_PROVIDERS]);

Here is a part of reflective_provider.js file that falls with error:

exports.mergeResolvedReflectiveProviders = mergeResolvedReflectiveProviders;
function _normalizeProviders(providers, res) {
    providers.forEach(function (b) {
        if (b instanceof lang_1.Type) {
            res.push(provider_1.provide(b, { useClass: b }));
        }
        else if (b instanceof provider_1.Provider) {
            res.push(b);
        }
        else if (provider_util_1.isProviderLiteral(b)) {
            res.push(provider_util_1.createProvider(b));
        }
        else if (b instanceof Array) {
            _normalizeProviders(b, res);
        }
        else if (b instanceof provider_1.ProviderBuilder) {
            throw new reflective_exceptions_1.InvalidProviderError(b.token);
        }
        else {
>>>         throw new reflective_exceptions_1.InvalidProviderError(b); // LINE 163
        }
    });
    return res;
}

Any ideas?

TonGarcia commented 8 years ago

How did you installed it on ionic? Did you perform the npm install? I'm getting error while installing by NPM.

npm ERR! Tell the author that this fails on your system:
npm ERR!     typings install
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs angular2-devise-token-auth
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls angular2-devise-token-auth