Angular 2 error: "unknown element" issue persists despite exhausting all attempted solutions

Here's a typical scenario where I attempt to incorporate a component from another module :

External component :

import { Component, ViewEncapsulation,
  ElementRef, ViewChild, Input, Output,
  EventEmitter } from '@angular/core';

declare var __moduleName: string

@Component({
  moduleId:    __moduleName,
  selector:    'thingamajig',
  templateUrl: 'thingamajig.html',
  styleUrls:   [],
  encapsulation: ViewEncapsulation.None
})
export class ThingamajigComponent {

  @Input() config: { }

  constructor(protected elRef: ElementRef) {
  }

}
// template : <p>basic text</p>

External module :

import { NgModule }       from '@angular/core';
import { CommonModule }   from '@angular/common';

import { ThingamajigComponent } from './thingamajig'

@NgModule({
  imports: [
  ],
  declarations: [
    ThingamajigComponent
  ],
  exports: [
    ThingamajigComponent
  ]
})
export class ThingamajigModule {}

Main component :

...
import { ThingamajigComponent }       from '../../thingamajig/thingamajig'
...
// template : <thingamajig></thingamajig>

Main module :

import { ThingamajigModule }          from '../../thingamajig/module'
// ...
@NgModule({
  imports: [
    // ...
    ThingamajigModule
  ]
})

I believe all the necessary checks have been performed:

If you have any insights or suggestions, they would be greatly appreciated. Thank you!

("thingamajig" is the English equivalent of the French word "bidule")

Answer №1

To incorporate the functionality of the Foreign module into the Main module, simply import the Foreign module within the Main module and insert the <bidule></bidule> tag into any component within the Main Module. It is correct that you should export the BiduleComponent, but there is no need to directly import it into the Main Component. Importing the Foreign Module into the Main Module will suffice.

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

What is the best way to troubleshoot the TypeScript error I am encountering in my JavaScript file?

Currently experiencing a TypeScript error within a JavaScript file The issue is within a folder containing only one JavaScript file, and there are no Node.js or package.json files present. I have disabled the TypeScript extensions (not using tslint). Re ...

How to Modify a Module that was Imported in Typescript

Apologies for my inexperience in this language. I've been working on a custom Discord bot and encountered a problem. I implemented the feature to load commands dynamically from a folder, with each command as a module. However, when trying to create a ...

Disable menu bar | customize menu bar in electronJS

I am developing an Angular application with Electron.js. Due to the specific design requirements of my app, which is browser-based, I do not require or want the default Electron.js menu or menu bar to be displayed. Is there a way to remove it from my app ...

How can you transfer array elements to a new array using JavaScript?

I have a task to transform the fields of an array received from one server so that they can be understood by another server for upload. My approach involves first retrieving and displaying the original field names from the initial server's array to al ...

Tips for extracting information from Observable that is supplied with data from an external API

Beginner in the world of Reactive programming (and Angular). I’m eager to create my first data stream and receive something other than an error message in the console output :) Here is what I've attempted: export class AppComponent { requestS ...

Can Angular Universal SSR be activated specifically for Googlebot User Agents?

I am aiming to activate Angular Universal SSR only when the User Agent is identified as Googlebot. However, I am uncertain about how to instruct Angular Universal SSR to deliver server side rendered HTML exclusively if the User Agent is Googlebot. server ...

Discovering an entry that lacks a specific value within an array in the records

Currently, I am utilizing sequelize along with typescript in a node environment (with a postgresql database). Here is the model that I have defined: id: number, someField: string, arr1: number[], arr2: number[] My objective is to retrieve all records wher ...

Modify information in formArray

Let's take a look at this setup I have: Model: export class MapDetailModel{ id: number; lat: number; lon: number; alt: number; long: number; angle: number; distance?: number; pendenza?: number; } Html: <div clas ...

Steps for developing a collaborative module

New to the world of Ionic/Angular development, my project structure looks like this: - src -- /app ---- app.component.ts ---- app.module.ts ---- main.ts ---- ... -- /pages ---- /event-home ------ /event-home.module.ts ------ /event-home.ts event-home.mod ...

Is it possible to have an interface, function, and variable all sharing the same name in a declaration?

Is it possible to have an interface, function, and variable all with the same name? For example, I would like to define the function as follows: declare function someName(...args: any[]); someName('foo'); The interface would look like this: ...

Combine both typescript and javascript files within a single Angular project

Is it feasible to include both TypeScript and JavaScript files within the same Angular project? I am working on a significant Angular project and considering migrating it to TypeScript without having to rename all files to .ts and address any resulting er ...

Error: unable to locate module that was imported from

Every time I try to run the project using this command, an error pops up: > npm run build npm info using <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c7a9b7aa87fee9f1e9f0">[email protected]</a> npm info using ...

Activate OnChanges by modifying a property within the object that is bound to the data

Is there a way to make ngOnChanges() fire when a property of a data-bound object changes without needing to assign a new object to the property? // Inside the component @Input() myObj: ObjType; // Component code... The above scenario does not trigger the ...

What are the best strategies for managing npm dependencies alongside other packages?

I am working on an Angular app that has the following dependencies: "dependencies": { "personalUiLibrary": "1.0.0" }, "devDependencies": { "tailwindcss": "^2.2.7" } In the personalUiLibrary p ...

Using Angular 2 to pass a function as an argument to a constructor

How can I create a custom @Component factory where a function is called to return a component, passing the widgetName to the constructor or super constructor? export function createCustomKendoComponent(selector: string, **widgetName**: string) { @Co ...

Issue with displaying MP4 movies in Angular

I'm trying to display an mp4 video in Angular 9: <video controls (click)="toggleVideo()" preload="none" *ngIf="post.moviePath != null" #videoPlayer> <source [src]="getMovieSanitazePath(post.moviePath ...

Issue encountered during ng2-redux installation

While attempting to use the https://www.npmjs.com/package/ng2-redux link, I encountered an issue when running npm install redux ng2-redux --save. Here is the stacktrace of the error: npm ERR! Windows_NT 6.1.7601 npm ERR! argv "C:\\Program Files& ...

Retrieving the selected date from mat-datepicker into a FormControl

When creating a POST request to an API, I encountered an issue with the mat-datepicker field as it throws an error when inside the ngOnInit() call (since nothing is selected yet). Other fields like name, email, etc. work fine, but extracting a value from t ...

When a file is modified in Angular, it triggers an error prompting the need to restart the 'npm' service

Whenever I make changes to a file in my Angular application, I encounter the following error: ERROR in ./src/app/@theme/components/auth/index.js Module build failed: Error: ENOENT: no such file or directory, open 'C:\Dev\Ng\ngx-a ...

Explore a vast array of items in a collection

I have a massive collection of various objects that I need to sift through. With over 60,000 elements, the search operation can sometimes be painfully slow. One typical object in this array has the following structure: { "title": "title" "company": ...