Encountered Error in Angular2 Reactive Form: Unable to Override Property Stack of [object Object] - Getter Only

I encountered an issue while trying to set up an angular2 reactive form, as I am getting a runtime error when the component loads.

Uncaught TypeError: Cannot set property stack of [object Object] which has only a getter

The error message is not very clear, making it difficult for me to understand what exactly is causing the problem. I have been following a tutorial on an angular university article, but so far I haven't found any solutions. I thought there might be some breaking changes in Angular 2, so I checked the changelog but didn't find anything related to my specific issue with reactive forms.

Any assistance or guidance on how to resolve this error would be greatly appreciated. I will continue investigating to find a solution.

addevent.component.ts

@Component({
  selector: 'addevent',
  templateUrl: 'addevent.component.html',
  styleUrls: ['addevent.scss']
})
export class AddEvent {

  // vars
  private _addEventForm:FormGroup;
  private _eventTitle:FormControl;
  private _eventDescription:FormControl;

  constructor(private _addEventService:AddEventService,
              private _formBuilder:FormBuilder) {
    // init vars
    this._eventTitle = new FormControl('', Validators.required);
    this._eventDescription = new FormControl('', Validators.required);
    this._addEventForm = _formBuilder.group({
      'eventTitle': this._eventTitle,
      'eventDescription': this._eventDescription
    });
  }

  private addEvent():void {
    console.log(this._addEventForm);
    //this._addEventService.addEvent();
  }

}

addevent.component.html

<div class="h3 content-title">Add Event</div>

<form [formGroup]="_addEventForm" (ngSubmit)="addEvent()">
  <p>
    <label>Title</label>
    <input type="text" formControlName="eventTitle">
  </p>
  <p>
    <label>Description</label>
    <input type="text" formControlName="eventDescription">
  </p>
  <p>
    <button type="submit" [disabled]="_addEventForm.invalid">Submit</button>
  </p>
</form>

dashboard.module.ts

@NgModule({
  declarations: [Dashboard, Navbar, Sidebar, Home, Profile, Events, AddEvent],
  imports: [BrowserModule, FormsModule, ReactiveFormsModule, HttpModule],
  providers: [ContentSwap, SidebarActivity, AuthService, FirebaseAuthService]
})
export class DashboardModule {}

Answer №1

There are occasions when I encounter the same issue. It appears to be a glitch in the most recent version of zonejs/angular. To pinpoint your exact error, try setting a breakpoint on the stack where the error originates. The actual error will likely be an input parameter for the function that is causing the crash.

If you require additional information, refer to https://github.com/angular/zone.js/issues/427

Answer №2

While troubleshooting an issue with angular/zone.js, I came across a helpful comment that guided me towards identifying the root cause of the problem.

An error occurred: uncaught TypeError: Cannot create property 'configurable' on string 'Error: No provider for AddEventService!

It turns out, the issue was simply due to missing a provider for a new service I had implemented.

Answer №3

During my experience, I encountered a problem with a chrome extension that was causing an error. By setting a break point at the exact location of the failure in zone.js, I was able to identify the troublesome extension. After obtaining the extension ID, I disabled it in chrome and everything worked smoothly again.

Answer №4

Encountered an issue where I mistakenly applied two decorators on a @ViewChild element while utilizing the ngxs library, known for its emphasis on immutability. The code snippet below demonstrates the scenario:

  import { Select } from '@ngxs/store';

  // @Select(AppLoginAPIState.getAuthenticatedUser) // uncomment to produce the error
  @ViewChild('redirectCheckModal')
  redirectCheckModal: ModalComponent;

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

During the installation of npm in my angular project directory, an error occurred

Encountered an error while installing packages (npm)...npm ERR! code ERR_SOCKET_TIMEOUT npm ERR! errno ERR_SOCKET_TIMEOUT npm ERR! network Received an invalid response when trying to fetch https://registry.npmjs.org/@babel%2fplugin-proposal-nullish-coalesc ...

The issue of broken reactivity arises when utilizing defineStore in Pinia with options instead of storeSetup

In my current project, I've implemented two different types of Pinia storage definitions. Here's a condensed look at each: // First Storage Definition using storeSetup export const useStore = defineStore("storeId", () => { const isExpanded: ...

What is the process for converting this example into a TypeScript class?

Currently in the process of developing an application using the H5P plug-in, I came across the need to create something for the H5P editor. This led me to discover this documentation on implementing a widget. /** * Module for Color selector widget * * @ ...

Showing items selected in reverse order in a mat-select with multiple selection, and direction displaying

Utilizing the Mat-select feature with multiple options. I have arranged my data using a custom order pipe. The direction has been set to rtl, resulting in the correct ordering of items, however, the selected items' inner text appears reversed. For ...

Triggering a function when a bound property changes in Aurelia

I'm currently working with a viewmodel that seems to be functioning correctly. @connectTo<State>({ selector: (store) => store.state.pipe(pluck('domain')).pipe(pluck('games')), target: 'games', }) @connectTo& ...

The @Input() function is failing to display or fetch the latest value that was passed

I am currently working on an angular project, and I've encountered a situation where I'm attempting to send a value from a parent component to a child component using the @Input() decorator. Despite my efforts, the child component continues to di ...

Finding a solution for duplicate date selections in NextJS using react-calendar

I am currently working on a calendar component using NextJS, typescript, tailwindcss, and the react-calendar library. I have encountered an issue with duplicate dates appearing in the calendar when selecting a date range. Although I have managed to handle ...

Creating a pop-up modal in an Angular2 application that incorporates a child

Can anyone help me figure out how to use Ng Bootstrap Modal with a child component as the modal body? I'm unsure of the best way to achieve this... export class ParentComponent { @ViewChild("modal") private engineModal: TemplateRef<any>; ...

Utilize REST API to submit information into the database during the login process

I'm currently working on an API that needs to verify if a user exists in the database. However, I'm facing challenges in posting data from the input fields to the API for user login functionality. Below is a snippet of the HTML code for the logi ...

Custom options titled MUI Palette - The property 'primary' is not found in the 'TypeBackground' type

I am currently working on expanding the MUI palette to include my own custom properties. Here is the code I have been using: declare module '@mui/material/styles' { interface Palette { border: Palette['primary'] background: Pa ...

Tips for integrating JavaScript libraries with TypeScript

I'm looking to add the 'react-keydown' module to my project, but I'm having trouble finding typings for it. Can someone guide me on how to integrate this module into my TypeScript project? ...

Angular function implementing a promise with a return statement and using the then method

I have a function in which I need to return an empty string twice (see return ''. When I use catch error, it is functioning properly. However, I am struggling to modify the function so that the catch error is no longer needed. This is my current ...

Encountering both a CORS error and data in Angular 7

My application is using Angular 7 for the front end and Node.js (express) for the backend. The cors module in the Node.js server.js file is implemented like this: var cors = require('cors') app.use(cors()); When making an API call from the fro ...

Tips for importing queries from a .graphql file using Angular and TypeScript

I am currently developing an app using Angular and Ionic. For the backend, I have set up a node server running ApolloServer with Neo4j (utilizing grandstarter.io). On the frontend, I have a file named queries.ts where I define my graphql queries in the fol ...

Error: Unable to access 'nativeElement' property from undefined object when trying to read HTML element in Angular with Jasmine testing

There is a failure in the below case, while the same scenario passes in another location. it('login labels', () => { const terms = fixture.nativeElement as HTMLElement; expect(terms.querySelector('#LoginUsernameLabel')?.tex ...

What seems to be the issue with my @typescript-eslint/member-ordering settings?

I am encountering an issue where my lint commands are failing right away with the error message shown below: Configuration for rule "@typescript-eslint/member-ordering" is throwing an error: The value ["signature","public-static-field","pro ...

A guide on cycling through the data within the input fields

Here's my code snippet: <div class="form-group row text-right" *ngFor='let row of vipInput'> <label class="col-sm-3 form-control-label m-t-5" for="password-h-f"></label> <div class="col-sm-9 form-control-label m-t-5 ...

The date selector is failing to accurately reflect changes in the date objects

I've integrated a date-time picker from this source https://github.com/DanielYKPan/date-time-picker to manage 'beginning' and 'end' date objects (refer to selectedMoments in the TypeScript code) for a date selector. However, when I ...

Angular 2 - Directive fails to work if not properly imported into its module

Trying to use a directive across multiple modules in Angular can be tricky. If you declare it in a shared module and import that module into other modules, you might encounter errors. It seems like the directive only works when declared directly within the ...

Issue: The inject() function must be activated within an injection context, however, the origin cannot be located

While utilizing angularfire's authentication service for user registration and login in my application, I encountered an error when triggering the register or sign-in method: Error: inject() must be called from an injection context Despite attempting ...