Error message stating that an attempt to read the property 'query' of a null object has failed

I encountered an issue with my Angular2 code:

import 'babel-polyfill';
import 'zone.js/dist/zone';
import { bootstrap } from "@angular/platform-browser-dynamic";

import { Component, ViewChild } from '@core';
import Other from "./Other";

@Component({
    selector: "app",
    templateUrl: "app.html",
//  directives: [Other]
})
export default class AppComponent {

//  @ViewChild(Other) other: Other;

    constructor() {
    }
}

bootstrap(AppComponent);

When I uncomment the commented lines, I receive the following error:

EXCEPTION: TypeError: Cannot read property 'query' of null (index):68
EXCEPTION: Error: Uncaught (in promise): TypeError: Cannot read property 'query' of null (index):76
STACKTRACE:window.console.error @ (index):76
BrowserDomAdapter.logError @ browser_adapter.js:77
ExceptionHandler.call @ exception_handler.js:59
(anonymous function) @ application_ref.js:265
schedulerFn @ async.js:123
SafeSubscriber.__tryOrUnsub @ Subscriber.js:225
SafeSubscriber.next @ Subscriber.js:174
Subscriber._next @ Subscriber.js:124
Subscriber.next @ Subscriber.js:88
Subject._finalNext @ Subject.js:128
Subject._next @ Subject.js:120
Subject.next @ Subject.js:77
EventEmitter.emit @ async.js:112
NgZone._zoneImpl.ng_zone_impl_1.
NgZoneImpl.onError @ ng_zone.js:120
NgZoneImpl.inner.inner.fork.onHandleError @ ng_zone_impl.js:66
ZoneDelegate.handleError @ zone.js:327
Zone.runGuarded @ zone.js:233
_loop_1 @ zone.js:487
drainMicroTaskQueue @ zone.js:494
ZoneTask.invoke @ zone.js:426 (index):76
...
(index):76
Unhandled Promise rejection:window.console.error @ (index):76
consoleError @ zone.js:461
_loop_1 @ zone.js:490
drainMicroTaskQueue @ zone.js:494
ZoneTask.invoke @ zone.js:426
(index):76
Error: Uncaught (in promise): TypeError: Cannot read property 'query' of null(…)window.console.error @ (index):76
consoleError @ zone.js:463
_loop_1 @ zone.js:490
drainMicroTaskQueue @ zone.js:494
ZoneTask.invoke @ zone.js:426
socket.io.js:5120 
Uncaught RangeError: Maximum call stack size exceeded

Answer №1

The reason for this issue was that the class Other contained a constructor with two arguments. Once I eliminated those arguments, everything functioned properly.

The error message itself is quite peculiar.

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 proper method for utilizing the --force flag in npm install when carrying out a Visual Studio publishing procedure?

Recently, while attempting to publish my Angular project in Visual Studio using a publish profile for IIS, I encountered unexpected dependency issues. This is puzzling because when running the project from the source (IIS Express), there are no such proble ...

Struggling to retrieve the ID from the API within the Angular and .NET Core component

Currently, I am working on a test project to enhance my knowledge of Angular. However, I have encountered an issue where the student's id fetched from the service is null. To handle the data, I have implemented a StudentController. Below is a snippet ...

Display only the selected view

Here is a snippet of the template I am working on: <tbody *ngFor='let list of lists'> <tr> <td>{{ list.name }}</td> <td>{{ list.location }}</td> ...

Refining dates in the Angular Material Calendar by utilizing two lists obtained from asynchronous sources

I am facing a challenge with disabling certain dates on a Material Calendar. These dates are sourced from two different places. The first set of dates come from within an object (camper) that is provided as input. The second set comes from an API call that ...

Using javascript to filter an array of JSON data

I'm contemplating how to streamline my filter code below. It's designed to filter out all JSON strings from a JSON array that contain specified values in one of three specific JSON string keys. My Visual Studio seems to be laughing at me, questio ...

Why is my Angular 2 project showing a 404 error when refreshing the page on App Engine?

I am encountering a similar issue to a question on Stack Overflow, but unfortunately, I don't have enough points to comment on it. The question is about making Angular 2 routing work with App Engine on page refresh. In my case, the problem is with a ...

How to fix the TS4090 error regarding conflicting definitions for a node in Visual Studio 2017

My TypeScript project is building and running, but I'm encountering a multitude of build errors all originating from one issue: TS4090: (TS) Conflicting definitions for 'node' found at 'C:/[projectpath]/node_modules/@types/node/index ...

What is the best way to utilize a single npm module in multiple TypeScript files?

Question: I keep encountering the error message "error TS2451: Cannot redeclare block-scoped variable 'os'" when I try to import the same npm module in multiple TypeScript files and run the TypeScript compiler tsc. Here is an overview of my proj ...

Replace interface with a string

Is it possible to override an interface with a string in TypeScript? Consider this example: type RankList = "Manager" | "Staff" interface EmployeeList { id: string, name: string, department: string, rank: "Staff&q ...

Using Angular to fetch API response and convert it into a promise

I've been following the Angular tutorial available at https://angular.io/tutorial/toh-pt6. The tutorial demonstrates how to retrieve a Json response from an API call and then match it to a promise. One specific example from the tutorial is as follows ...

Fixed-top navigation bar in Bootstrap

Currently working on constructing a Single Page Application (SPA) using Bootstrap, where the navbar is fixed-top. Encountering an issue where content gets cut off by the navbar unless setting the element margin-top to 58px. Although using the specified sty ...

What sets apart the two methods of defining an event in a React component?

Can you explain the nuances between these two approaches to declaring events in a React component? Is it merely a matter of personal preference, or are there more subtle distinctions between them? interface PropsX { onClick: () => void; } const But ...

Issue with setting active slide value in ng2 Bootstrap Carousel – constantly defaults to slide 1

My current project implementation involves using . Although I have successfully implemented it, I am encountering an issue where slide 1 remains active at all times. I am unsure how to remove the active class from slide 1. The main challenge lies in sett ...

An error occurred while trying to upload the image: Undefined property 'subscribe' cannot be read

Recently, I implemented a create post function that allows users to fill in the title, content, and upload an image. However, I encountered an issue where the progress bar fills up and the image gets uploaded to Firebase successfully, but it doesn't a ...

Is it possible to integrate the Firestore npm library into my Express application?

Recently, I created my own library to act as a nosql database on my node.js web server in place of mongodb. I came across this interesting quote: Applications that use Google's Server SDKs should not be used in end-user environments, such as on pho ...

find the element in cypress with multiple child elements

Looking for a way to target the first HTML element that contains more than 2 children. Another option is to access the children elements of the first parent element. <div class="market-template-2-columns"> <button type="button&q ...

Tips for integrating a variety of components onto a single webpage

Exploring the functionality of Angular, I am looking to include multiple components on a single page. How can this be achieved effectively in Angular? I envision each div representing a distinct component and view, with all components residing in separate ...

Error message for react-native useRoute hook: Property '.....' is not found within the object type

Currently in my expo app, I am utilizing the useRoute() hook within a functional component from react-navigation while also incorporating typescript. The specific route I am attempting to navigate to only requires one parameter: identificationUrl Howeve ...

Creating a JSX syntax for a simulated component and ensuring it is fully typed with TypeScript

Looking for some innovative ideas on how to approach this challenge. I have a test helper utils with added types: import { jest } from '@jest/globals' import React from 'react' // https://learn.reactnativeschool.com/courses/781007/lect ...

What is the process for running ng serve in a local environment following an ng build?

Utilizing Angular 4, I have created a new package by running the command ng build --prod. How can I test this new package locally in the folder dist/package? ...