Troubleshooting an issue in app.module.ts related to a custom selector tag in Ionic 4

Currently, I am working with Ionic 4 and Angular 7.

In the past, I had experience with Ionic3, and it seems that there have been some changes as well.

I am facing an issue while trying to implement a page using a custom selector tag

<app-side-menu></app-side-menu>
in the file app.component.html

The error I encounter is:

Uncaught Error: Template parse errors: 'app-side-menu' is not a known element: 1. If 'app-side-menu' is an Angular component, then verify that it is part of this module.

I have experimented with other pages where it works fine, leading me to believe that the problem lies only within the app.component.ts

Here is the snippet from app.component.html

    <ion-app>
      <ion-split-pane>
          <ion-menu>
              <ion-header>
                  <ion-toolbar>
                    <ion-title>
                      Menu
                    </ion-title>
                  </ion-toolbar>
                </ion-header>

                <ion-content>
                    <app-side-menu></app-side-menu>
                </ion-content>
          </ion-menu>
          <ion-router-outlet main></ion-router-outlet>

      </ion-split-pane>
    </ion-app>

And here's the content of app.module.ts

    import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';

import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { SideMenuPageModule } from './side-menu/side-menu.module';

@NgModule({
  declarations: [AppComponent],
  entryComponents: [],
  imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule],
  providers: [
    StatusBar,
    SplashScreen,
    { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
  ],
  exports : [
    SideMenuPageModule
  ],
  bootstrap: [AppComponent]
})
export class AppModule {}

Lastly, the details from side-menu.module.ts

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { Routes, RouterModule } from '@angular/router';

import { IonicModule } from '@ionic/angular';

import { SideMenuPage } from './side-menu.page';

const routes: Routes = [
  {
    path: '',
    component: SideMenuPage
  }
];

@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    IonicModule,
    RouterModule.forChild(routes)
  ],
  declarations: [SideMenuPage]
})
export class SideMenuPageModule {}

Answer №1

Per @Jason White's suggestion, I decided to showcase the side menu page independently from the router-outlet.

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

Troubleshooting Angular 7 Build Failure: Missing Typescript .d.ts Declaration Files for Ahead-of-Time Compilation

I have encountered difficulties in building my Angular 7 application after upgrading from v6. When I use ng build, everything runs smoothly. However, when I try either ng serve --aot, ng build --aot, or ng build --prod (which also includes aot), an error ...

The rationale behind making arrays const in Typescript

Currently, I am utilizing VS Code along with TSLint. In one instance, TSLint recommended that I change the declaration of an array variable from let to const, providing this code snippet: let pages = []; "Identifier 'pages' is never reassign ...

Getting the keys of an object where the values are of a certain type using TypeScript

Currently, I'm tackling a standard filter function (excuse the technical jargon) The main goal is to create a matcher function that compares a specified property (propertyName: keyof T) of an object (item: T) with a search term (term: string). type P ...

Using *ngIf within *ngFor: A guide

I need to determine if an employee is present or absent and display a corresponding badge. A green badge should be displayed for "present" status, while a red badge should be displayed for "absent" status. <tr *ngFor="let item of attendance; let i ...

Include a new module in the declarations NgModule utilizing ts-morph

Currently, I am utilizing the ts-morph library and my objective is to add a new component to the declarations: This is my initial setup: @NgModule({ declarations: [], imports: [], providers: [], }) Here is what I am aiming for: @NgModule({ declarations: [ ...

Determining a quaternion through the combination of two angles

I am currently working on a script that allows the THREE.js camera to rotate based on input from a mobile phone's gyroscope. While the functionality is mostly working fine, I have noticed an issue where the camera abruptly turns 180 degrees when cross ...

Error in VueJS: A linting issue is occurring with the message "JSX element type 'X' does not have any construct or call signatures" when attempting to globally register components

Everything seems to be in working order. I have successfully utilized the components and managed to build the app without encountering any issues. However, my text editor (VS Code) continues to throw a linting error even after attempting to register my own ...

Create Joi Schema based on TypeScript types/interfaces

Searching for a way to convert Typescript types or interfaces into joi schema objects led me to various solutions that did the opposite, such as generating Typescript types/interfaces from joi schemas. I came across options like ts-interface-builder and ts ...

ReactJS Typescript Material UI Modular Dialog Component

Hello, I need help with creating a Reusable Material UI Modal Dialog component. It's supposed to show up whenever I click the button on any component, but for some reason, it's not displaying. Here's the code snippet: *********************TH ...

Tips for sending information in a POST request as a query string parameter in Angular using HttpParams

When passing data as a query string parameter using POST method in Angular8 with HttpParams, I noticed that the API is not forming correctly and the request header is also incorrect. Please review the code below and provide any suggestions you may have. c ...

Combining an array into another array using the same key in JavaScript

My goal is to merge the array itself and transform it into a more meaningful array array = [ {item: 'pen', madeIn: 'US', color: 'blue'}, {item: 'pen', madeIn: 'US', color: 'white'}, {item: ' ...

Regex struggles to identify words containing foreign characters

Here is a method I have created to check if a user-input term matches any blacklisted terms: static checkAgainstBlacklist(blacklistTerms, term) { return blacklistTerms.some(word => (new RegExp(`\\b${word}\\b`, 'i&ap ...

Ionic: Fixed button located at the bottom of a specific ion-slide

I've been creating a series of slides with questions, and the final slide serves as a summary of the previously answered questions. I want to ensure that the submit button is always visible at the bottom of this last slide. However, I've encounte ...

Leverage properties within the storybook component template

When utilizing a class component in a narrative, it allows you to transmit properties as arguments: const Template: Story<MyComponent> = (args) => ({ props: args, component: MyComponent, }) export const Default = Template.bind({}); export co ...

Is there a way to customize the hover style of Material UI Select or Menu MenuItem using the theme?

The theme I designed import { createMuiTheme } from 'material-ui/styles'; export const MyTheme = createMuiTheme({ palette: { primary: { light: '#757ce8', main: '#3f50 ...

Is there a way to tally up the overall count of digits in a number using TypeScript?

Creating a number variable named temp in TypeScript: temp: number = 0.123; Is there a way to determine the total count of digits in a number (in this case, it's 3)? ...

Exploring the method to deactivate and verify a checkbox by searching within an array of values in my TypeScript file

I am working on a project where I have a select field with checkboxes. My goal is to disable and check the checkboxes based on values from a string array. I am using Angular in my .ts file. this.claimNames = any[]; <div class="row container"> ...

What is the best way to retrieve and showcase data in NextJs version 13 and beyond?

Being new to NextJS, my question may seem trivial but I'd appreciate your patience. Essentially, my goal is to fetch data from a database and display it on the page upon the initial render. To achieve this, I am utilizing the useEffect and useState ho ...

What is the best way to transform a unicode string into JSON format?

Looking to transform the Unicode string below into a JSON Object. var str = '{"method_title":"Bank. Transfer","instructions":"Account Name: Sriram Me Co.,Ltd.\r\n-------------------------------------------- ...

What is the best way to ensure image alignment is correct before displaying mat-error in Angular Material?

Having an issue with aligning an image with a mat error message in my Angular Material application. I've tried using matprefix but it's restricted to mat-form-field only. Any suggestions on how to properly align the image with the text? HTML < ...