Error Message: "Unknown Element Encountered: Lazy Loading Angular / Ionic 3 Component AOT"

Having some trouble with Lazy loading my Ionic components. Everything works fine in development, but when I try to compile AOT throws an error. Spent hours trying different solutions and still stuck on the same error.

I've checked examples and everything seems correct. What could I be 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.

Answer №1

Shoutout to @Joel Joseph for the help - Turns out, the view must be in the same folder as your parent component. I made the mistake of placing the view .html file in a separate shared directory which caused some issues.

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

was updated to

templateUrl: 'list.html'

and now everything compiles smoothly. Keeping this post here just in case others encounter the same problem.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The Flux Router in React Native

I am diving into the world of React Native and currently working on creating a practice app. The issue I'm facing is with the routing functionality in my project. At the moment, I have three main components: the app itself, the router component, and o ...

Obtain all subelements from the entity

In my Vue project, I am attempting to collect and POST some values to the server. However, I am finding the current implementation to be somewhat frustrating. Within a Vue method, I have a function that POSTs the collected values from the original object: ...

A comprehensive guide to dynamically rendering components and implementing dynamic CSS in Angular 6

I successfully implemented a Directive, but I am now facing the challenge of adding CSS styling to it. I have experimented with array objects, however, I ended up applying CSS directly in the HTML. My goal is to create a single component where I can pass ...

Use the ng-pattern regex to specifically identify instances where a pattern occurs only once

Looking for a string pattern 'abcd' followed by a colon(:) and any number of integers, with the restriction that this pattern cannot be repeated. Here are some examples of valid patterns: - abcd:23415 - abcd:23 And invalid patterns: - asda:4 ...

The canvas's document.getElementById function is unable to find any matching element,

Hello everyone, I am currently diving into the world of javascript and trying to expand my knowledge. However, I have encountered a problem that has me stumped, and I could really use some assistance. While exploring, I came across this page: http://www.w ...

Express.js using GET request to retrieve all data entries from the database

I am facing a challenge in retrieving specific user data using the GET method on Express.js through a Form. Instead of returning only one user's information, it is currently returning all values when the form is used. Here is the code from index.html ...

JSON.parse encountered an unexpected character that is not whitespace following the JSON data

I'm having trouble fetching data from the database using the json object. Whenever I call the servlet, jQuery returns SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data. This error seems to occur only when the response contai ...

The date displayed in moment.js remains static even after submitting a new transaction, as it continues to hold onto the previous date until

I am currently utilizing moment.js for date formatting and storing it in the database This is the schema code that I have implemented: const Schema = new mongoose.Schema({ transactionTime: { type: Date, default: moment().toDate(), ...

Tips for submitting AJAX information instead of traditional form data

I am trying to send a simple input field as JSON data to a web server that I have set up. Here is what I have tried so far: <html> <head> <script src="http://code.jquery.com/jquery-1.11.3.js"></script> <script> $(document).r ...

Creating an aperture in a form using a different shape in THREE.js

Currently, I am utilizing the D3-threeD2.js library to convert SVG files into THREE.Shape(s) that can be extruded with three.js. The process works smoothly, however, when it comes to incorporating holes, I encounter an issue. Imagine a shape resembling a ...

When utilizing Next.js with TypeScript, you may encounter an error message stating that the property 'className' is not found on the type 'IntrinsicAttributes & IntrinsicClassAttributes'

I recently put together a basic nextjs app using typescript. Here's the link to the example: https://github.com/zeit/next.js/tree/master/examples/with-typescript However, I encountered an issue where I am unable to add the className attribute to any ...

Order elements by their ratings in descending order using jQuery and then conceal divs according to their values

I am attempting to accomplish the following task. I have twelve divs structured like this: <div id=1><div>test 1</div><div>4</div></div> <div id=2><div>test2</div><div>1</div></div&g ...

Sorting information in the React Native Section List

Working with React Native's SectionList and filtering data: data: [ { title: "Asia", data: ["Taj Mahal", "Great Wall of China", "Petra"] }, { title: "South America", data: ["Machu Picchu", "Christ the Redeemer", "C ...

Combining Angular with Google Maps

Currently, I am utilizing angular-googlemaps(agm) and it has been functioning well for me so far. However, I have a requirement to search for an address using latitude and longitude. After some research, I discovered a partial solution here. The only issu ...

Creating enduring designs in Next.js

I've been diving into this amazing article and I'm puzzling over the implementation of persistence in Option 4. It seems like you would need to redefine the .getLayout method for each page. I'm uncertain about how nesting logic is handled fo ...

How to extract the last five words from a .txt file in PHP by utilizing the file_get_contents

Is there a way to efficiently read the last 5 words from a .txt file using file_get_contents during long-polling? I attempted to implement a solution using the code below, but it interferes with the long-polling process – which functions properly when di ...

Updating the model does not reflect changes made to AGM polygons' binding

<div *ngFor="let p of polys"> <agm-polygon #cmp [paths]="$any(p.getPath()).i" [fillColor]="'blue'" [draggable]="true" [editable]="true" [polyDraggable]="true" (p ...

JavaScript - Sending Form Data with Local Time

I want to automatically submit a form at a specific time of day The form should be submitted every day at "15:30:00" Here is the JavaScript code I have written: <script type="text/javascript> function initClock() { var now = new Date(); var h ...

Uncertainty surrounding the concept of JavaScript objects

What is the reason for this not functioning properly? function displayValue(a,b){ this.a = a; this.b = b; $('p').text(a + " " + b); } var display = new displayValue(); display('1','2'); How does this still work ...

Interactive jQuery element featuring an image gallery displayed within a translucent black overlay on a webpage

My goal is to add a jQuery popup with an image that appears automatically when a website loads. I envision the popup creating a black transparent overlay, similar to this example. While setting up the basic popup was straightforward, integrating the image ...