The tag was not successfully added to the ngx-chips model

I'm struggling to grasp how a new entry can be added to the array of objects specified in the directory.

Currently, I am using the ngx-chips library which you can find here.

You can view the sample code I created by clicking on this link.

Here is the ngx-chip directive:

<tag-input [ngModel]="items" (onAdd)="onFilterRuleAdded($event)"></tag-input>

Essentially, whenever I add a new chip, it doesn't appear in my items. The console logs show that the items remain unchanged - no new entries are added.

Can anyone advise me on how I can ensure that each new entry from the tag-input is added to the designated model items?

Answer №1

Discover it.

Realized that I forgot to implement two-way binding.

Check out this post

Essentially, I just activated the two-way binding

Here is the functional snippet:

<tag-input [(ngModel)]="items" (onAdd)="onFilterRuleAdded($event)"></tag-input>

Pay attention to the [(ngModel)] syntax

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 could be the reason for ngOnChanges lifecycle hook not getting invoked?

I am currently experimenting with Angular 2 in an effort to learn more about it. I noticed that ngOnChanges is not triggering in the code below: app.component.ts: import { Component, Input } from "@angular/core" import { FormsModule } from '@angular ...

The 'never[]' type does not contain the specified property. What could be the issue?

Hi there, I'm just diving into the world of React+Typescript. I'm facing an issue with my code where I am trying to print a property from a JSON object onto the console. The data is coming in successfully from the server, but when I attempt to ou ...

Incorporated React Router and TypeScript to enhance functionality for matching

While Connected React Router does export types for RouterState, there seems to be a missing typings for match. Ideally, the typings could also be imported and included in the reducer just like how RouterState is used below and in the reducer: https://gith ...

Tips for ensuring proper dependency regulations in javascript/typescript/webpack

In essence, I am in search of a method to limit dependencies, similar to how one would manage different projects (libraries) in Java or C#. Think of it as friend or internal access modifiers. I'm considering various approaches to accomplish this (suc ...

The imported variables are of a union type

In my nextjs project, I developed a customized hook to determine if a specific container is within the viewport using the intersection observer. Here's the code for the custom hook: import { useEffect, useRef, useState } from 'react'; cons ...

Having trouble with importing a TypeScript class: encountering a "cannot resolve" error message

Could you lend me your expertise? I'm puzzled by this issue that seems to be quite simple and straightforward: export class Rectangle { height: number = 0 width: number = 0 constructor(height: number, width: number) { this. ...

Leverage functionalities from the rxjs npm package within an Angular application without the need for npm install

In the midst of updating my Angular 4 application to use rxjs version 6.3+, I discovered that many changes in rxjs are causing issues with my existing codebase. One of the new features we need to implement requires this update, but it's proving to be ...

Ionic Angular encountered an unexpected 'ERROR' without any detailed explanation or logging

https://i.sstatic.net/aJPD1.png Hey there, I'm encountering some issues with my Ionic App. Currently, I am executing ionic cordova run android --livereload --consolelogs --serverlogs using a physical device. Although I can see console.logs, there ...

Angular 2 module that is loaded lazily - service does not follow singleton pattern

After successfully implementing lazy loading modules into my application, I have ensured that the app.module.ts is properly configured. @NgModule({ declarations: [ AppComponent, HeaderComponent, HomeComponent ], imports: [ BrowserMod ...

Unable to connect to 'formGroup' as it is not recognized as a valid attribute of 'form'. ("<div class="upload-right"><div class="signup">

In my Angular 7 project, I am struggling to identify where the error lies within this form. The error message keeps stating that 'form' is not a known property of this method. Can someone please point out where I went wrong in the following code ...

Adjust the specific data type to match its relevant category

Is there a method to alter literal types in TypeScript, for instance. type T1 = ""; type T2 = 1 I am interested in obtaining string for T1 and number for T2. Regarding collections, I am unsure, but I assume it would involve applying it to the generic typ ...

Ways to implement distinct service instances for several child components in Angular 2

I have been working on an application that features multiple instances of a similar master-details view along with a search box. To streamline the process, I decided to create a separate module for this common functionality and establish communication betw ...

Utilize the .mat-column-name attributes to apply custom styles to a nested component within Angular Material

Within the Child component, an Angular material table is created with columns passed as input: <table mat-table> <ng-container *ngFor="let col of columns" [matColumnDef]="col"> </table> @Input() columns: string[] T ...

Automating HTML5 input and datalist item selection using Selenium

My goal is to use Selenium to select an item from a dropdown list. Despite several attempts, I have been unable to achieve this. The issue seems to be related to the input tag referring to a datalist. String baseUrl = "https://angular-cwmwke.stackblit ...

Passing the state variable from a hook function to a separate component

I have a hook function or file where I need to export a state named 'isAuthenticated'. However, when I try to import this state using import {isAuthenticated} from '../AuthService/AuthRoute', I encounter an import error. My goal is to m ...

Problem with Jasmine in Angular 5 within Visual Studio Code

I am completely new to Angular 5 Unit testing and facing some challenges. Despite installing all @types/jasmine, I am encountering errors in my spec.ts file such as 'describle is not a name' and 'jasmine.createSpyObj does not exist on the ty ...

The inner map function isn't being executed in Rxjs

I have written some code that utilizes two pipes to load a product instance along with its playlist. In case there is an error while loading the playlist, the property is set to null: getProduct(productId: number): Observable<ProductDTO> { retur ...

Error: Virtual script not located; possibly absent <script lang="ts" / "allowJs": true / within the jsconfig.json.volar

https://i.sstatic.net/dFaVQ.png I noticed an error in my footer component in VueJs (TypeScript template) as depicted by the image showing blue squiggly lines. ...

Is a special *ngFor required when implementing Angular2 with Nativescript?

My current project involves creating a mobile app that requires listing a few labels. Here is the code snippet: @Component({ selector: 'code-m', template: ` <StackLayout dock="top" orientation="vertical" style="height: ...

The error message "Undefined error in Angular 8 when waiting for API call to finish" appears when

if(this.datashare.selectedtableId!=null) { console.log( "inside if condition"); let resp= this.http.get(this.global.apiUrl+"columns/"+this.datashare.selectedtableId); resp.subscribe((data)=>this.users=data); conso ...