Lazy Loading Angular / Ionic 3 Component AOT “is not a known element: Error”












0















This is driving me crazy, hopefully someone can shed some light on the problem. I am Lazy loading my Ionic components everything works fine in development, however when I go to compile AOT throws an error. I spent about 4 hours trying different ways to load this in I am lost, keep getting the same error.



From what I read and found in examples this should be correct. What am I missing here?



'tester' is not a known element: 1. If 'tester' is an Angular component, then verify that it is part of this 
module. 2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
<ion-list *ngIf="!id"> <ion-list-header> [ERROR -><tester></tester>


//  components/tester/tester.ts

import { Component } from '@angular/core';
@Component({
selector: 'tester',
templateUrl: 'tester.html'
})
export class TesterComponent {

text: string;

constructor() {
console.log('Hello TesterComponent Component');
this.text = 'Hello World';
}

}


// components/components.module.ts

import { NgModule } from '@angular/core';
import { TesterComponent } from './tester/tester';
import {IonicModule} from "ionic-angular";
@NgModule({
declarations: [TesterComponent],
imports: [IonicModule],
exports: [TesterComponent,
]
})
export class ComponentsModule {}


//  pages/faq/faq.module.ts

import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { FaqPage } from './faq';
import {ComponentsModule} from "../../components/components.module";

@NgModule({
declarations: [
FaqPage
],
imports: [
IonicPageModule.forChild(FaqPage), ComponentsModule
],
})
export class FaqPageModule {}


// pages/faq/faq.html
<tester></tester>


EDIT



Thanks to @Joel Joseph - Apparently the view needs to reside in the same directory as your parent component. I had the view .html file in a shared directory hence the problem.



templateUrl: '../shared/view/list.html'


changed to



templateUrl: 'list.html'


and it compiles fine now. Will leave this up incase anyone else has this issue.










share|improve this question

























  • can you post the code in your main router for the root module or app.module.ts where you have lazy loaded the feature modules

    – Joel Joseph
    Nov 26 '18 at 4:46













  • also make sure you use these syntax to lazy load the feature module {path: '', loadChildren: '../views/views.module#ViewsModule'},

    – Joel Joseph
    Nov 26 '18 at 4:48













  • if you have used any other syntax it will end up in the error

    – Joel Joseph
    Nov 26 '18 at 4:51











  • @Joel Joseph - Thanks man. Yup that was the issue. Apparently the view needs to reside in the same directory as your parent component. I had the view .html file in a shared directory hence the problem. Thanks again.

    – limit
    Nov 26 '18 at 6:14
















0















This is driving me crazy, hopefully someone can shed some light on the problem. I am Lazy loading my Ionic components everything works fine in development, however when I go to compile AOT throws an error. I spent about 4 hours trying different ways to load this in I am lost, keep getting the same error.



From what I read and found in examples this should be correct. What am I missing here?



'tester' is not a known element: 1. If 'tester' is an Angular component, then verify that it is part of this 
module. 2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
<ion-list *ngIf="!id"> <ion-list-header> [ERROR -><tester></tester>


//  components/tester/tester.ts

import { Component } from '@angular/core';
@Component({
selector: 'tester',
templateUrl: 'tester.html'
})
export class TesterComponent {

text: string;

constructor() {
console.log('Hello TesterComponent Component');
this.text = 'Hello World';
}

}


// components/components.module.ts

import { NgModule } from '@angular/core';
import { TesterComponent } from './tester/tester';
import {IonicModule} from "ionic-angular";
@NgModule({
declarations: [TesterComponent],
imports: [IonicModule],
exports: [TesterComponent,
]
})
export class ComponentsModule {}


//  pages/faq/faq.module.ts

import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { FaqPage } from './faq';
import {ComponentsModule} from "../../components/components.module";

@NgModule({
declarations: [
FaqPage
],
imports: [
IonicPageModule.forChild(FaqPage), ComponentsModule
],
})
export class FaqPageModule {}


// pages/faq/faq.html
<tester></tester>


EDIT



Thanks to @Joel Joseph - Apparently the view needs to reside in the same directory as your parent component. I had the view .html file in a shared directory hence the problem.



templateUrl: '../shared/view/list.html'


changed to



templateUrl: 'list.html'


and it compiles fine now. Will leave this up incase anyone else has this issue.










share|improve this question

























  • can you post the code in your main router for the root module or app.module.ts where you have lazy loaded the feature modules

    – Joel Joseph
    Nov 26 '18 at 4:46













  • also make sure you use these syntax to lazy load the feature module {path: '', loadChildren: '../views/views.module#ViewsModule'},

    – Joel Joseph
    Nov 26 '18 at 4:48













  • if you have used any other syntax it will end up in the error

    – Joel Joseph
    Nov 26 '18 at 4:51











  • @Joel Joseph - Thanks man. Yup that was the issue. Apparently the view needs to reside in the same directory as your parent component. I had the view .html file in a shared directory hence the problem. Thanks again.

    – limit
    Nov 26 '18 at 6:14














0












0








0


1






This is driving me crazy, hopefully someone can shed some light on the problem. I am Lazy loading my Ionic components everything works fine in development, however when I go to compile AOT throws an error. I spent about 4 hours trying different ways to load this in I am lost, keep getting the same error.



From what I read and found in examples this should be correct. What am I missing here?



'tester' is not a known element: 1. If 'tester' is an Angular component, then verify that it is part of this 
module. 2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
<ion-list *ngIf="!id"> <ion-list-header> [ERROR -><tester></tester>


//  components/tester/tester.ts

import { Component } from '@angular/core';
@Component({
selector: 'tester',
templateUrl: 'tester.html'
})
export class TesterComponent {

text: string;

constructor() {
console.log('Hello TesterComponent Component');
this.text = 'Hello World';
}

}


// components/components.module.ts

import { NgModule } from '@angular/core';
import { TesterComponent } from './tester/tester';
import {IonicModule} from "ionic-angular";
@NgModule({
declarations: [TesterComponent],
imports: [IonicModule],
exports: [TesterComponent,
]
})
export class ComponentsModule {}


//  pages/faq/faq.module.ts

import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { FaqPage } from './faq';
import {ComponentsModule} from "../../components/components.module";

@NgModule({
declarations: [
FaqPage
],
imports: [
IonicPageModule.forChild(FaqPage), ComponentsModule
],
})
export class FaqPageModule {}


// pages/faq/faq.html
<tester></tester>


EDIT



Thanks to @Joel Joseph - Apparently the view needs to reside in the same directory as your parent component. I had the view .html file in a shared directory hence the problem.



templateUrl: '../shared/view/list.html'


changed to



templateUrl: 'list.html'


and it compiles fine now. Will leave this up incase anyone else has this issue.










share|improve this question
















This is driving me crazy, hopefully someone can shed some light on the problem. I am Lazy loading my Ionic components everything works fine in development, however when I go to compile AOT throws an error. I spent about 4 hours trying different ways to load this in I am lost, keep getting the same error.



From what I read and found in examples this should be correct. What am I missing here?



'tester' is not a known element: 1. If 'tester' is an Angular component, then verify that it is part of this 
module. 2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
<ion-list *ngIf="!id"> <ion-list-header> [ERROR -><tester></tester>


//  components/tester/tester.ts

import { Component } from '@angular/core';
@Component({
selector: 'tester',
templateUrl: 'tester.html'
})
export class TesterComponent {

text: string;

constructor() {
console.log('Hello TesterComponent Component');
this.text = 'Hello World';
}

}


// components/components.module.ts

import { NgModule } from '@angular/core';
import { TesterComponent } from './tester/tester';
import {IonicModule} from "ionic-angular";
@NgModule({
declarations: [TesterComponent],
imports: [IonicModule],
exports: [TesterComponent,
]
})
export class ComponentsModule {}


//  pages/faq/faq.module.ts

import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { FaqPage } from './faq';
import {ComponentsModule} from "../../components/components.module";

@NgModule({
declarations: [
FaqPage
],
imports: [
IonicPageModule.forChild(FaqPage), ComponentsModule
],
})
export class FaqPageModule {}


// pages/faq/faq.html
<tester></tester>


EDIT



Thanks to @Joel Joseph - Apparently the view needs to reside in the same directory as your parent component. I had the view .html file in a shared directory hence the problem.



templateUrl: '../shared/view/list.html'


changed to



templateUrl: 'list.html'


and it compiles fine now. Will leave this up incase anyone else has this issue.







javascript angular typescript ionic-framework ionic3






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 26 '18 at 6:19







limit

















asked Nov 25 '18 at 22:45









limitlimit

352418




352418













  • can you post the code in your main router for the root module or app.module.ts where you have lazy loaded the feature modules

    – Joel Joseph
    Nov 26 '18 at 4:46













  • also make sure you use these syntax to lazy load the feature module {path: '', loadChildren: '../views/views.module#ViewsModule'},

    – Joel Joseph
    Nov 26 '18 at 4:48













  • if you have used any other syntax it will end up in the error

    – Joel Joseph
    Nov 26 '18 at 4:51











  • @Joel Joseph - Thanks man. Yup that was the issue. Apparently the view needs to reside in the same directory as your parent component. I had the view .html file in a shared directory hence the problem. Thanks again.

    – limit
    Nov 26 '18 at 6:14



















  • can you post the code in your main router for the root module or app.module.ts where you have lazy loaded the feature modules

    – Joel Joseph
    Nov 26 '18 at 4:46













  • also make sure you use these syntax to lazy load the feature module {path: '', loadChildren: '../views/views.module#ViewsModule'},

    – Joel Joseph
    Nov 26 '18 at 4:48













  • if you have used any other syntax it will end up in the error

    – Joel Joseph
    Nov 26 '18 at 4:51











  • @Joel Joseph - Thanks man. Yup that was the issue. Apparently the view needs to reside in the same directory as your parent component. I had the view .html file in a shared directory hence the problem. Thanks again.

    – limit
    Nov 26 '18 at 6:14

















can you post the code in your main router for the root module or app.module.ts where you have lazy loaded the feature modules

– Joel Joseph
Nov 26 '18 at 4:46







can you post the code in your main router for the root module or app.module.ts where you have lazy loaded the feature modules

– Joel Joseph
Nov 26 '18 at 4:46















also make sure you use these syntax to lazy load the feature module {path: '', loadChildren: '../views/views.module#ViewsModule'},

– Joel Joseph
Nov 26 '18 at 4:48







also make sure you use these syntax to lazy load the feature module {path: '', loadChildren: '../views/views.module#ViewsModule'},

– Joel Joseph
Nov 26 '18 at 4:48















if you have used any other syntax it will end up in the error

– Joel Joseph
Nov 26 '18 at 4:51





if you have used any other syntax it will end up in the error

– Joel Joseph
Nov 26 '18 at 4:51













@Joel Joseph - Thanks man. Yup that was the issue. Apparently the view needs to reside in the same directory as your parent component. I had the view .html file in a shared directory hence the problem. Thanks again.

– limit
Nov 26 '18 at 6:14





@Joel Joseph - Thanks man. Yup that was the issue. Apparently the view needs to reside in the same directory as your parent component. I had the view .html file in a shared directory hence the problem. Thanks again.

– limit
Nov 26 '18 at 6:14












1 Answer
1






active

oldest

votes


















0














Thanks to @Joel Joseph - Apparently the view needs to reside in the same directory as your parent component. I had the view .html file in a shared directory hence the problem.



templateUrl: '../shared/view/list.html'


changed to



templateUrl: 'list.html'


and it compiles fine now. Will leave this up incase anyone else has this issue.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53472761%2flazy-loading-angular-ionic-3-component-aot-is-not-a-known-element-error%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Thanks to @Joel Joseph - Apparently the view needs to reside in the same directory as your parent component. I had the view .html file in a shared directory hence the problem.



    templateUrl: '../shared/view/list.html'


    changed to



    templateUrl: 'list.html'


    and it compiles fine now. Will leave this up incase anyone else has this issue.






    share|improve this answer




























      0














      Thanks to @Joel Joseph - Apparently the view needs to reside in the same directory as your parent component. I had the view .html file in a shared directory hence the problem.



      templateUrl: '../shared/view/list.html'


      changed to



      templateUrl: 'list.html'


      and it compiles fine now. Will leave this up incase anyone else has this issue.






      share|improve this answer


























        0












        0








        0







        Thanks to @Joel Joseph - Apparently the view needs to reside in the same directory as your parent component. I had the view .html file in a shared directory hence the problem.



        templateUrl: '../shared/view/list.html'


        changed to



        templateUrl: 'list.html'


        and it compiles fine now. Will leave this up incase anyone else has this issue.






        share|improve this answer













        Thanks to @Joel Joseph - Apparently the view needs to reside in the same directory as your parent component. I had the view .html file in a shared directory hence the problem.



        templateUrl: '../shared/view/list.html'


        changed to



        templateUrl: 'list.html'


        and it compiles fine now. Will leave this up incase anyone else has this issue.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 26 '18 at 6:20









        limitlimit

        352418




        352418
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53472761%2flazy-loading-angular-ionic-3-component-aot-is-not-a-known-element-error%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            404 Error Contact Form 7 ajax form submitting

            How to know if a Active Directory user can login interactively

            Refactoring coordinates for Minecraft Pi buildings written in Python