原始异常:TypeError:无法读取undefined /build/js/app.bundle.js:38545的属性'parameters'

时间:2016-07-29 11:25:23

标签: typescript ionic-framework firebase ionic2 firebase-authentication

每当我取消注释代码的注释部分时,我都会收到以下错误。

EXCEPTION: Error in ./MyApp class MyApp - inline template:0:0 
/build/js/app.bundle.js:38545
ORIGINAL EXCEPTION: TypeError: Cannot read property 'parameters' of
undefined  /build/js/app.bundle.js:38545
ORIGINAL STACKTRACE:  /build/js/app.bundle.js:38545

TypeError: Cannot read property 'parameters' of undefined at
ReflectionCapabilities.parameters (/build/js/app.bundle.js:34268:40)
at Reflector.parameters (/build/js/app.bundle.js:34472:48) at
CompileMetadataResolver.getDependenciesMetadata
(/build/js/app.bundle.js:13559:86) at
CompileMetadataResolver.getTypeMetadata
(/build/js/app.bundle.js:13508:26) at /build/js/app.bundle.js:13662:30
at Array.map (native) at CompileMetadataResolver.getProvidersMetadata
(/build/js/app.bundle.js:13650:26) at
CompileMetadataResolver.getDirectiveMetadata
(/build/js/app.bundle.js:13459:34) at RuntimeCompiler.resolveComponent
(/build/js/app.bundle.js:17355:47) at NavController.loadPage
(/build/js/app.bundle.js:55071:24)  /build/js/app.bundle.js:38545

....然后继续

该部分应该检查user是否已登录并设置rootPage但是它失败并显示错误。请帮忙

import {LoginPage} from './pages/login/login';
import * as firebase from 'firebase';

import {Component} from '@angular/core';
import {Platform, ionicBootstrap} from 'ionic-angular';
import {StatusBar} from 'ionic-native';
import {HomePage} from './pages/home/home';


@Component({
  template: '<ion-nav [root]="rootPage"></ion-nav>'
})
export class MyApp {
  rootPage: any = HomePage;

  constructor(platform: Platform) {
  	// Initialize Firebase
	  var config = {
	    apiKey: "AIzaSyDvrfwEXb2iyYXud_27tzJZ3Bcer28DkMg",
	    authDomain: "fir-auth-d5ba1.firebaseapp.com",
	    databaseURL: "https://fir-auth-d5ba1.firebaseio.com",
	    storageBucket: "fir-auth-d5ba1.appspot.com",
	  };

	firebase.initializeApp(config);

	/*firebase.auth().onAuthStateChanged(function(user){
	  if (user) {
	    // If there's a user take him to the home page.
	    this.rootPage = HomePage;
	  } else {
	    // If there's no user logged in send him to the LoginPage
	    this.rootPage = LoginPage;
	  }
	});*/

    platform.ready().
    then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      StatusBar.styleDefault();
    });
  }
}
ionicBootstrap(MyApp);

0 个答案:

没有答案