运行离子cordova build android --prod时出错

时间:2017-07-19 21:09:33

标签: angular ionic-framework ionic2

我在运行之前看不到的ionic cordova build android --prod 时遇到错误:

Error: Unexpected token: name (AccountDetailsPageModuleInjector) in C:\Users\dlemburg\Desktop\sba\client-user\www\build\0.main.js at line 35, col 6, pos 1240

运行时没有错误:

ionic cordova build android(没有--prod标志)
ionic run android(也没有旗帜)
ionic serve(直接在浏览器中运行)

AccountDetailsPage的相关代码:

import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, ToastController, ModalController, AlertController, LoadingController } from 'ionic-angular';
import { Validation } from '../../utils/validation-utils';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { API, ROUTES } from '../../global/api';
import { Authentication } from '../../global/authentication';
import { BaseViewController } from '../base-view-controller/base-view-controller';
import { AppViewData } from '../../global/app-data.service';
import { AuthUserInfo } from '../../models/models';

@IonicPage()
@Component({
  selector: 'page-account-details',
  templateUrl: 'account-details.html'
})
export class AccountDetailsPage extends BaseViewController {
  myForm: FormGroup;
  logoImgSrc: string;
  auth: AuthUserInfo;
  appHeaderBarLogo: string;
  companyName: string;

    constructor(
      public navCtrl: NavController, 
      public navParams: NavParams, 
      public API: API, 
      public authentication: Authentication, 
      public modalCtrl: ModalController, 
      public alertCtrl: AlertController, 
      public toastCtrl: ToastController, 
      public loadingCtrl: LoadingController, 
      private formBuilder: FormBuilder ) {

      super(alertCtrl, toastCtrl, loadingCtrl);

      this.myForm = this.formBuilder.group({
        firstName: [null, Validators.required],
        lastName: [null, Validators.required],
        email: [null, Validators.compose([Validators.required, Validation.test("isEmail")])],
        zipcode: [null, Validators.compose([Validators.required, Validation.test('isZipCode')])],
        hasPushNotifications: [true, Validators.required]
      });
      this.logoImgSrc = AppViewData.getImg().logoImgSrc;
      this.auth = this.authentication.getCurrentUser();
      this.appHeaderBarLogo = AppViewData.getImg().logoImgSrc;
      this.companyName = this.auth.companyName;
  }

  ionViewDidLoad() {
    this.presentLoading();

    this.API.stack(ROUTES.getUserAccountDetails, "POST", {userOid: this.auth.userOid})
      .subscribe(
          (response) => {
            console.log('response: ', response);
            this.dismissLoading();
            let {firstName, lastName, email, zipcode, hasPushNotifications} = response.data.accountDetails;
            this.myForm.patchValue({firstName, lastName, email, zipcode, hasPushNotifications });

          }, this.errorHandler(this.ERROR_TYPES.API));
  } 

  submit(myForm) {
    this.presentLoading(AppViewData.getLoading().saving);
    let toData = {toData: myForm, userOid: this.auth.userOid};
    this.API.stack(ROUTES.editUserAccountDetails, "POST", toData)
      .subscribe(
          (response) => {
            this.dismissLoading(AppViewData.getLoading().saved);
            setTimeout(() => {
              this.navCtrl.setRoot("HomePage");
            }, 1000);
            console.log('response: ', response);
          },  this.errorHandler(this.ERROR_TYPES.API));
  }
}
来自AccountDetailsModule的相关代码:

import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { AccountDetailsPage } from './account-details';

import { ControlMessagesComponentModule } from '../../components/control-messages/control-messages.component.module';
import { CompanyLogoComponentModule } from '../../components/company-logo/company-logo.component.module';
import { AppHeaderBarComponentModule } from '../../components/app-header-bar/app-header-bar.component.module';


@NgModule({
  declarations: [
    AccountDetailsPage
  ],
  imports: [
    IonicPageModule.forChild(AccountDetailsPage),
    ControlMessagesComponentModule,
    CompanyLogoComponentModule,
    AppHeaderBarComponentModule
  ],
  exports: [
    AccountDetailsPage
  ]
})
export class AccountDetailsPageModule {}

在AccountDetailsModule中导航页面时,我没有任何未捕获的错误,也没有打字稿中的任何构建错误。

环顾0.main.js,但对我看到的内容并不太确定。我假设 SomePage ModuleInjector是内部角度或webpack作为延迟加载的一部分?

有谁知道导致此错误的原因是什么?

0 个答案:

没有答案