Unable to link to 'amount' because it is not a recognized attribute of 'ng-wrapper'

I recently made some changes to my code and now I'm encountering the error message "Can't bind to 'count' since it isn't a known property of 'ng-container'"

Instead of having both the notification component and notification-widget component,

I have decided to remove the notification component and only keep the notification-widget component.

The original code, which was working properly:

notification-widget.component.html

<div class="af-notification-widget">
    <notification [count]="config.count"></notification>
</div>

notification-widget.component.ts

import { Component, OnInit, Input } from '@angular/core';
import { NotificationConfigComponent } from '../../widget-creator/notification-config/notification-config.component';

@Component({
  selector: 'notification-widget',
  templateUrl: './notification-widget.component.html',
  styleUrls: ['./notification-widget.component.scss']
})
export class NotificationWidgetComponent implements OnInit {
  @Input() config: NotificationConfigComponent;

  constructor() { }

  ngOnInit() { }
}

notification.component.html

<ng-container *ngFor="let item of items; let i = index">
  <ng-container *ngIf="i < count">
    <div class="af-notification"
         (click)="itemRead(i)"
         routerLink="/budgeting/{{ item.url }}">
      <div class="af-notification__content">
        <span class="af-notification__title"
              [class.read]="item['read'] == true">{{ item['title'] }}
        </span>
        <span class="af-notification__description">{{ item['description'] }}</span>
        <span class="af-notification__date-time">{{ item['date'] }}</span>
      </div>
  </ng-container>
</ng-container>

notification.component.ts

import { Component, Input, OnInit } from '@angular/core';

@Component({
  selector: 'notification',
  templateUrl: './notification.component.html',
  styleUrls: ['./notification.component.scss']
})
export class NotificationComponent implements OnInit {
  @Input() data: any;
  @Input() count: number;
  items = [
    {
      title: 'Import of .......... failed',
      description:
        'Lorem ipsum dolor sit amet, consectetur adipiscing elit',
      date: '27/08/2019',
      read: true
    },
    {
      title: 'Manager ..........approved the budget and prices',
      description:
        'Lorem ipsum dolor sit amet, consectetur adipiscing elit',
      date: '26/08/2019',
      read: true
    },
    {
      title: 'Manager ..........approved the budget',
      description:
        'Lorem ipsum dolor sit amet, consectetur adipiscing elit',
      date: '26/08/2019',
      read: true
    }
  ];

  constructor() { }

  deleteWidget(i) {
    this.items.splice(i, 1);
  }
  itemRead(i) {
    if (this.items[i].read == false) {
      this.items[i].read = true;
    }
  }
  ngOnInit() { }
}

After removing the notification component and integrating its functionality into the notification-widget component, I am puzzled by the appearance of the error - "Can't bind to 'count' since it isn't a known property of 'ng-container"

Answer №1

It is recommended to remove the @Input decorator from the count property, as it is being defined within the same component

Answer №2

It has been pointed out by others that count is not a property of ng-container, which explains why your code isn't functioning correctly. To fix this issue, you'll need to delete the [count]=config.count assignment within your ng-container. Additionally, you can remove the @input() count: number; since count is no longer being assigned. Lastly, make sure to update any references to count in your HTML file to config.count instead. Once these changes are made, your code should work as expected!

Answer №3

When troubleshooting my issue, I found that removing the property ('') was the solution.

//prior to fixing the error

@Input() ('title') title: any;

Error message: Unable to bind to 'title' as it is not a recognized property of 'ng-container'

//after fixing the issue

@Input() title: any;

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

Tips for preventing the error message "The property 'map' is not present on type 'string | string[]'."

I received an error message stating Property 'map' does not exist on type 'string | string[]': const data = [ ['1', ['11']], ['2', ['21']], ['3', ['31']], ] data.map(top ...

Show the login form and accompanying controls in the center of the screen with Angular 6

Currently, I am working on developing a Reactive form using Angular 6. In my TypeScript file, I have successfully obtained the form instance along with form controls. The next step involves iterating through these form controls and displaying the user inpu ...

Upgrade from Next.js version 12

Greetings to all! I have recently been assigned the task of migrating a project from next.js version 12 to the latest version. The changes in page routing and app routing are posing some challenges for me as I attempt to migrate the entire website. Is ther ...

Why am I encountering this issue? The "map" property does not appear to be available for the type "Observable<boolean>"

I have been working on an Angular project where I am utilizing an AuthGuard class to prevent unauthorized access to protected pages. Despite following an online course, I encountered the following issue: import { CanActivate, ActivatedRouteSnapshot, Router ...

Row Model for Server-Side Processing

Looking to maintain the default loading overlay while serverSideRowModel functions are invoked in my Angular app, and prevent the loading spinner from showing up during data fetching. ...

What is the best way to pass down SectionList prop types in TypeScript when using React?

I am working on creating a wrapper for SectionList in React Native that needs to accept all the standard props of SectionList along with some custom ones. How can I set up typescript to accommodate this? Here is what I have tried: import React from &apos ...

Angular Chart.js is throwing an error: "Uncaught SyntaxError: Cannot use import statement outside a module"

Upon opening the page, an error in the console related to Chart.js 4.2.1 is being displayed. Description of first image. Description of second image. Is it possible that this issue solely lies with Chart.js? How can it be resolved? To address the proble ...

A step-by-step guide on incorporating a .env file into a React JS project that is written with TypeScript

I'm currently working on a React JS project with TypeScript. I know that we can utilize a .env file to define some configurations, like so: .env file REACT_APP_SOME_CONFIGURATION = "some value" We can then use these configurations in our c ...

What causes TypeScript's ReadonlyArrays to become mutable once they are transpiled to JavaScript?

Currently, I am in the process of learning Typescript by referring to the resources provided in the official documentation. Specifically, while going through the Interfaces section, I came across the following statement: TypeScript includes a special t ...

The Application Insights Javascript trackException function is giving an error message that states: "Method Failed: 'Unknown'"

I've been testing out AppInsights and implementing the code below: (Encountering a 500 error on fetch) private callMethod(): void { this._callMethodInternal(); } private async _callMethodInternal(): Promise<void> { try { await fetch("h ...

Identifying an SCSS file based on its class name in Angular

Currently, I'm utilizing an Angular 5 application with styles that are encapsulated within components. Upon running the ng serve command, all styles get inserted into <styles> tags within the <head> section of the page. This results in br ...

What is the best way to include an item in a list with a specific identifier using the useState Record data type in a React application built with TypeScript?

Here is the structure of my Record type: const PEOPLE_MAP_INIT: Record<string, Person[]> = { "1": [], "2": [], "3": [] }; I have initialized the useState like this: const [PEOPLE_MAP, SET_PEO ...

CDK Error: Unable to locate MethodResponse in AWS API Gateway configuration

I'm facing an issue in vscode while trying to access the MethodResponse interface from apigateway. Unfortunately, I'm getting an error message: The type 'typeof import(".../node_modules/aws-cdk-lib/aws-apigateway/index")' d ...

The triggering of Angular Change Detection does not occur when using nested ngFor loops

Currently, I'm deeply engrossed in a substantial Angular project that utilizes NgRx Store. One interesting feature of the app is an infinite scrolling list that displays skeleton items at the end, which are later replaced by real items once the reques ...

Using JavaScript to dynamically calculate the sum of selected column values in Angular Datatables

I have a table set up where, if a checkbox is checked, the amounts are automatically summed and displayed at the top. However, I am encountering issues with the code below as it is not providing the exact sum values. Can anyone suggest a solution to this p ...

Exploring the latest features of Angular 2's ngModel form to track user selections

Consider this form: <form name="setQuestions_form" (ngSubmit)="set_questions()"> <ng-select [multiple]="true" [options]="questions" [(ngModel)]="selectedQuestions" name="selectedQuestions"></ng-select> <button>send</butt ...

Managing errors with async/await in an Angular HttpClient function

I have been experimenting with an async/await pattern to manage a complex scenario that could potentially result in "callback hell" if approached differently. Below is a simplified version of the code. The actual implementation involves approximately 5 co ...

Middleware for Redux in Typescript

Converting a JavaScript-written React app to Typescript has been quite the challenge for me. The error messages are complex and difficult to decipher, especially when trying to create a simple middleware. I've spent about 5 hours trying to solve an er ...

Is there a way to customize the hover style of Material UI Select or Menu MenuItem using the theme?

The theme I designed import { createMuiTheme } from 'material-ui/styles'; export const MyTheme = createMuiTheme({ palette: { primary: { light: '#757ce8', main: '#3f50 ...

Navigating through Objects in Angular 9

I am facing a challenge in Angular 9/Typescript while trying to iterate through the object response from my JSON data. Despite searching for solutions, I haven't found any that work for me. In my JSON, there is a section called "details" which contain ...