Angular 4 - Error: Unable to call this.changeHook as it is not a function

![image or error ]1Encountering a strange issue in my Angular 4 application. When I type in input text boxes, an error message

TypeError: this.changeHook is not a function
appears in the console. I'm struggling to understand the cause of this error. Any suggestions?

****UPDATE**** The error seems to occur only for the second input text box and not the first one. Curiously, every character I type in the second box triggers the same error message multiple times in the console.

HTML


<ng-container *ngFor="let reasoncode of displayReasonCodes$ | async;let i = index">
 <tr class= "row-break">

 <checkbox type="checkbox"  name="sizecb[]" value="{{reasoncode.id}}"  [(ngModel)]="reasoncode.state">
      </checkbox>


       <td>  
          <form>
           <form-group>

  <textbox [readOnly]="isEditable" ngModel="{{reasoncode.ReasonCode}}"  name="textbox" ></textbox>
                                            </form-group>

                                    </form>

                            </td>
                            <td>
                                                     <form>
                                                            <form-group>

                                                              <textbox ngModel="{{reasoncode.Description}}" name="textbox1" ></textbox>
                                                            </form-group>

                                                    </form>

                            </td>

COMPONENT -

       
@Component({
    selector: 'app-reason-codes',
    templateUrl: './reason-codes.component.html',
    styleUrls: ['./reason-codes.component.scss'],
    providers: [ ReasonCodesActions],
    encapsulation: ViewEncapsulation.None,

})

export class ReasonCodesComponent implements OnInit {
    poolModel: ReasonCodeFormUIModel;

    IReasonCodes: IReasonCodes[]=[]; 

    i:any;
    @select(store.isReasonCodeLoading) isLoading$: Observable<boolean>;
    @select(store.displayReasonCodes) displayReasonCodes$:Observable<IReasonCodes>;
    @select(store.isDisplayMessage) displayMessage$: Observable<boolean>;
    @select(store.componentType) componentType$: Observable<number>;

    Active:any;

    addCodes:boolean;
    state:any;
     $event:any;
    displayReasonCodes:any;

    headers = [
        { label: 'REASON CODES ', sort: false },
        { label: 'DESCRIPTION', sort: false },
        { label: 'STATUS', sort :false}
    ];

    constructor(private reasonCodesActions : ReasonCodesActions,
        private uiActions:UIActions) {
    }

    ngOnInit (){
        this.displayReasonCodes$.subscribe(data=>this.result=data); 
        this.reasonCodesActions.getReasonCodes();
    }

    Addrow(){ 
        console.log("add");
        this.isEditable=false;
        this.reasonCodesActions.Addrow();
    }

    refresh(){
        location.reload();
    }                   

Answer №1

Identified the problem - Initially, I overlooked including any input property on the input field in my template. Consequently, it was unable to detect the input. After incorporating the input property, the error vanished from the console.

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

Encountering an issue where attempting to access the `toUpperCase` property of undefined in an *ngFor loop leads to an error

I encountered an issue when trying to specify an index in *ngFor, as I received a type error with the following message: <div class='text' *ngFor='let item of blogs; let i = index | async | filter : 'feat' : true'> Rem ...

The installed NPM package does not contain the necessary TypeScript compiled JS files and declaration files

I have recently released a TypeScript library on NPM. The GitHub repository's dist (Link to Repository Folder) directory includes all compiled JavaScript and d.ts files. However, after running npm i <my_package>, the resulting module contains on ...

Exploring Angular2's ability to interpret directive templates using the ng-container

Recently delving into angular2, I ventured into creating dynamic forms and generating fields by following the guide provided in this URL. The result was as expected. The dynamic form component renders each field one by one using ng-container, like shown b ...

Problem with Angular2, NodeJS, and Passport Integration

At the moment, my Angular2 front-end is running on localhost:3000 while the NodeJS back-end (using KrakenJS) is running on localhost:8000. When I input the credentials and make a call to the this.http.post('http://localhost:8000/login', body, { h ...

Achieve a main-menu container with a full width dropdown using Bootstrap 4

I want the dropdown to start from the initial position for all menus and maintain a width of 600px. Even if I attempt to open the dropdown for "Main Menu 2" or "Main Menu 3" or "Main Menu 4", the dropdown should always start from the position of "Main Men ...

Angular: Converting the outcome of a request to an observable

When working on my project, I decided to tackle it module by module to ensure each part had access to the user. However, as I refine the project, I'm encountering a situation where multiple API requests are being made for the same purpose (user info) ...

Getting the logged in user's ID in Angular using MongoDB and Node.js for the backend

How can I retrieve the logged user's ID so that when they click on "My profile", they are directed to url/profile/theirId? Thank you for your help! Below is my authentication.service code: export interface UserDetails{ username: string email: stri ...

Utilizing string literals as index signatures

I've created a code snippet called MyTest that maps over an object: type MyTest<T> = { [P in keyof T]: T[P]; }; type Result = MyTest<{hello: 'world', foo: 2}>; // ^? type Result = { hello: 'world', foo: 2 } ...

Is there a way to specifically identify modified values in Angular forms?

When working with Angular forms, what is the best method to detect fields that have been changed and no longer contain their original values? ...

How can the spacing between Angular Material's mat-card-content and mat-card-actions be adjusted?

I am creating a mat card layout where there are two separate cards within the main card's content section. However, when I add a button for the actions section of the main card, there is no spacing between these two sections. How can I create a vertic ...

Understand and extract data from a JSON array using Typescript

Here is a JSON response I received from a remote server: { "string": [ { "id": 223, "name": "String", "sug": "string", "description": "string", "jId": 530, "pcs": [{ "id": 24723, "name": "String", ...

Go to a specific component located in a different module within Angular

I have a default app.component that contains a button. When this button is clicked, I want to navigate to the login.component. Below is a snippet from my app.module.ts file: import { BrowserModule } from '@angular/platform-browser'; ...

Merging sort and uniq functionalities to create a single function in JavaScript

I've been working with the sortBy and uniqBy functions, but I find myself iterating over the array twice when using the combined sortUniqBy. If you want to check out the code, feel free to click on this link to the codesandbox. Here's a snippet o ...

Issue with exporting Typescript React component

Despite searching for answers, none of the related questions have been helpful... My goal is to export React components from a TypeScript library that I plan to publish on npm. For testing purposes before publishing, I am utilizing npm link. The structu ...

Struggling to transmit data to material dialog in Angular2+

I am facing an issue with my Material Dialog not working properly. Can anyone point out what I might be missing? product-thumbnail.ts I will use this to trigger the dialog export class ProductThumbnailComponent implements OnInit { @Input() product: Pr ...

Angular 16: Troubleshooting RxJs Problem with Updating Total in Header Component

Hello, I'm facing an issue with my Observable and need some guidance. Currently, I have a functional cart and checkout system that works well when adding items to the cart. It successfully manages total items and costs. These components are located a ...

Transform the data types in interfaces to promises

In Typescript, there is a Partial<Object> type that allows all fields of an object to be optional. Can we create a generic type Promisify<Person> in the same way, transforming the Person type from: interface Person { getName(): string; ge ...

What is the method for checking out sub, child, or inner components within a web browser?

In this screenshot, you can see the Left Panel where I have successfully generated the home component under the app component. I'm wondering how I can access or view this sub component inside the browser. When I try accessing it using http://localhos ...

Concealing tab bars on Ionic 2 secondary pages

In my Ionic Bootstrap configuration, I have the following setup: { mode: 'md', tabsHideOnSubPages: true } However, despite having this setting in place, the tabs still appear on some sub-pages. It seems to be happening randomly. Is there ...

Encountering unexpected errors with Typescript while trying to implement a simple @click event in Nuxt 3 projects

Encountering an error when utilizing @click in Nuxt3 with Typescript Issue: Type '($event: any) => void' is not compatible with type 'MouseEvent'.ts(2322) __VLS_types.ts(107, 56): The expected type is specified in the property ' ...