swamy
swamy

Reputation: 31

How to change data in .config.ts file in Angular

I need to display count on menu items, the menu is loading from menu.config.ts file. I need to bind count here which comes from API. How do I do that? Please suggest.

Menu.config.ts File code:

export class MenuConfig {
  public defaults: any = {
    aside: {
      self: {},
      items: [
         {
            title: 'New Orders',
            count: 10,            
          },
          {
            title: 'For Delivery',
            count: 25,           
          },
          {
            title: 'Delivered',
            count: 20,
          }
      ]
    }
  }
}

Menu component html:

<ng-template #menuItemTextTemplate let-item="item" let-parentItem="parentItem">
    <span class="menu-text" [translate]="item.translate">
        <h3 class="menu-text-count">{{item.count}}</h3>
        <p class="menu-text-label">{{item.title}}</p>
    </span>
</ng-template>

Upvotes: 1

Views: 458

Answers (1)

cagcak
cagcak

Reputation: 4170

Rewriting a file requires nodejs fs module which you cannot perform such an operation dynamically except during building the app.

You can use state management (ngrx, etc.) or localstorage or as scoped variable or living database (local or remote)

Upvotes: 3

Related Questions