0
votes

I am using Ionic.

Cordova CLI: 6.4.0 
Ionic Framework Version: 3.1.1
Ionic CLI Version: 2.1.18
Ionic App Lib Version: 2.1.9
Ionic App Scripts Version: 1.3.0
ios-deploy version: Not installed
ios-sim version: Not installed
OS: macOS Sierra
Node Version: v7.10.0
Xcode version: Xcode 8.3.2 Build version 8E2002

I get the following error:

core.es5.js:1084 ERROR Error: Uncaught (in promise): Error: Module build failed: Error: ENOENT: no such file or directory, open

'/Users/richardmarais/Development/ionic/theWhoZoo/src/pages/model/ratingModel.js' Error: Module build failed: Error: ENOENT: no such file or directory, open '/Users/richardmarais/Development/ionic/theWhoZoo/src/pages/model/ratingModel.js'

When I try access the following page:

review/review.ts

...
import { RatingModel } from '../model/ratingModel';

@IonicPage()
@Component({
  templateUrl: 'review.html'
})
export class ReviewPage {
...

model/ratingModel.ts

import { Injectable } from "@angular/core";
import { PersonModel } from './personModel';
import { JobModel } from './jobModel';

@Injectable()
export class RatingModel {
        public id: number = null;
        public job: JobModel = null;
        public review: string = null;
        public rating: number = null;
        public reviewDate: number = null;
        public time: string = null;
        public person: PersonModel = null;
        public anonymous: number = null;
}

This was working until I changed my pages to use lazy loading.

review/review.module.ts

import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { ReviewPage } from './review';
import { ControlMessagesModule } from '../validation/controlMessages.module';
import { RatingComponentUpdateableModule } from '../utils/rating/ratingComponentUpdateable.module';

@NgModule({
  declarations: [ReviewPage],
  imports: [IonicPageModule.forChild(ReviewPage), ControlMessagesModule, RatingComponentUpdateableModule],
  exports: [ReviewPage]
})
export class ReviewPageModule { }

UPDATE

I find the error occurs because of the following:

this.ratingModel = navParams.get('ratingModel');
if (!this.ratingModel) {
  this.ratingModel = new RatingModel();

when I remove the new RatingModel() line, I don't get any errors.

How are you supposed to create a new RatingModel?

1

1 Answers

1
votes

The problem here is you are making the model class an injectable.

@Injectable()
export class RatingModel {

You dont have to make a model class as injectable.

If you do need to do so, you will have to set it as a provider. Or try to get an object from the explicit injector.

 constructor(private injector: Injector) { }
 //..
 this.ratingModel = this.injector.get(RatingModel)