Error in Ionic 2: "No component factory found for"

0

I'm trying to show a new page in an app of ionic (the app was not created by me, I've only been asked to modify it ), when I execute this.navCtrl.push(aportacionesPage) it returns the following error:

  

No component factory found for AportacionesPage

I will try to be something more specific with my code even though I do not manage much ionic I do not know if it will be left over or missing.

In the imports I already have the page I want to go to

import { AportacionesPage } from '../aportaciones/aportaciones';

The page I want to go to is well built and has no compilation errors, the class is with the content of another page of the app that works well (I have also tried to do the push to that other page and works). The only thing that has changed its copy are the names.

@Component({
  selector: 'page-aportaciones',
  templateUrl: 'aportaciones.html'
})
export class AportacionesPage {
....
}

The push statement is executed in a click event

<div class="btn_aportaciones">
    <button (click)='irAportaciones()'>{{ 'foro-hilo.mis_aportaciones' | translate }}</button>    
  </div>

And the method is as follows:

irAportaciones(item) {     
    console.log("PRUEBA DEL LOG FUNCIONANDO");     
    this.navCtrl.push(aportaciones, {
      //view: 'order'
    }).then(
      response => {
        console.log('Response ' + response);
      },
      error => {
        console.log('Error: ' + error);
      }
    ).catch(exception => {
      console.log('Exception ' + exception);
    });      
  }

Clicking on the button shows me these errors:

  

EXCEPTION: Error in ./ForoHiloPage class ForumHiloPage - inline template: 76: 4 by: No component factory found for AportacionesPage   ErrorHandler.handleError @ main.js: 52944   IonicErrorHandler.handleError @ main.js: 110388   next @ main.js: 35926   schedulerFn @ main.js: 37436   SafeSubscriber .__ tryOrUnsub @ main.js: 12385   SafeSubscriber.next @ main.js: 12334   Subscriber._next @ main.js: 12287   Subscriber.next @ main.js: 12251   Subject.next @ main.js: 14484   EventEmitter.emit @ main.js: 37428   NgZone.triggerError @ main.js: 38278   onHandleError @ main.js: 38257   t.handleError @ polyfills.js: 3   e.runTask @ polyfills.js: 3   invoke @ polyfills.js: 3

  

ORIGINAL EXCEPTION: No component factory found for AportacionesPage   ErrorHandler.handleError @ main.js: 52946   IonicErrorHandler.handleError @ main.js: 110388   next @ main.js: 35926   schedulerFn @ main.js: 37436   SafeSubscriber .__ tryOrUnsub @ main.js: 12385   SafeSubscriber.next @ main.js: 12334   Subscriber._next @ main.js: 12287   Subscriber.next @ main.js: 12251   Subject.next @ main.js: 14484   EventEmitter.emit @ main.js: 37428   NgZone.triggerError @ main.js: 38278   onHandleError @ main.js: 38257   t.handleError @ polyfills.js: 3   e.runTask @ polyfills.js: 3   invoke @ polyfills.js: 3

  

ORIGINAL STACKTRACE:   ErrorHandler.handleError @ main.js: 52949   IonicErrorHandler.handleError @ main.js: 110388   next @ main.js: 35926   schedulerFn @ main.js: 37436   SafeSubscriber .__ tryOrUnsub @ main.js: 12385   SafeSubscriber.next @ main.js: 12334   Subscriber._next @ main.js: 12287   Subscriber.next @ main.js: 12251   Subject.next @ main.js: 14484   EventEmitter.emit @ main.js: 37428   NgZone.triggerError @ main.js: 38278   onHandleError @ main.js: 38257   t.handleError @ polyfills.js: 3   e.runTask @ polyfills.js: 3   invoke @ polyfills.js: 3

  

main.js: 52950 Error: No component factory found for ContributionsPage       at NoComponentFactoryError.BaseError [as constructor] (main.js: 7758)       at new NoComponentFactoryError (main.js: 24023)       at _NullComponentFactoryResolver.resolveComponentFactory (main.js: 24032)       at AppModuleInjector.CodegenComponentFactoryResolver.resolveComponentFactory (main.js: 24057)       at NavControllerBase._viewInit (main.js: 29941)       at NavControllerBase._nextTrns (main.js: 29773)       at NavControllerBase._queueTrns (main.js: 29744)       at NavControllerBase.push (main.js: 29588)       at ForoHiloPage.irAportaciones (main.js: 40843)       at CompiledTemplate.proxyViewClass.View_ForoHiloPage0.handleEvent_37 (component.ngfactory.js: 400)   ErrorHandler.handleError @ main.js: 52950   IonicErrorHandler.handleError @ main.js: 110388   next @ main.js: 35926   schedulerFn @ main.js: 37436   SafeSubscriber .__ tryOrUnsub @ main.js: 12385   SafeSubscriber.next @ main.js: 12334   Subscriber._next @ main.js: 12287   Subscriber.next @ main.js: 12251   Subject.next @ main.js: 14484   EventEmitter.emit @ main.js: 37428   NgZone.triggerError @ main.js: 38278   onHandleError @ main.js: 38257   t.handleError @ polyfills.js: 3   e.runTask @ polyfills.js: 3   invoke @ polyfills.js: 3

  

ERROR CONTEXT:   ErrorHandler.handleError @ main.js: 52953   IonicErrorHandler.handleError @ main.js: 110388   next @ main.js: 35926   schedulerFn @ main.js: 37436   SafeSubscriber .__ tryOrUnsub @ main.js: 12385   SafeSubscriber.next @ main.js: 12334   Subscriber._next @ main.js: 12287   Subscriber.next @ main.js: 12251   Subject.next @ main.js: 14484   EventEmitter.emit @ main.js: 37428   NgZone.triggerError @ main.js: 38278   onHandleError @ main.js: 38257   t.handleError @ polyfills.js: 3   e.runTask @ polyfills.js: 3   invoke @ polyfills.js: 3

    
asked by Lombarda Arda 31.01.2018 в 09:06
source

1 answer

0

For this case I only see the error of the reference to the variable aportaciones in the irAportaciones() method.

NavController Ionic Documentation

must be corrected by making the adjustment to the scope of the class where it is located as follows:

  

It is important to use this to access the properties of the class.

     

Although for this case you can save an additional property and put the dependency directly in this.navCtrl.push(AportacionesPage)

import { AportacionesPage } from '../aportaciones/aportaciones';

@Component({
  selector: 'page-aportaciones',
  templateUrl: 'aportaciones.html'
})
export class OtraPage {
  private aportaciones = AportacionesPage;

  irAportaciones() {
    console.log('PRUEBA DEL LOG FUNCIONANDO');
    this.navCtrl
      .push(this.aportaciones, {
        //view: 'order'
      })
      .then(
        (response) => {
          console.log('Response ' + response);
        },
        (error) => {
          console.log('Error: ' + error);
        }
      )
      .catch((exception) => {
        console.log('Exception ' + exception);
      });
  }
}
    
answered by 31.01.2018 в 22:31