标签未出现在角度菜单中

问题描述 投票:0回答:1

我使用primeng和angular。我创建了一个服务,当像参数一样传递un hash时返回一个字符串:

//this.propertiesName is and Object with all property that i need and this is just calculated read a json file
     getValueFromProperties(hash: string): string {
        return this.propertiesName[id];
      }

当我尝试访问属性时,该服务起作用,它返回了我的值。但是当我创建MenuItem时:

 items: MenuItem[];
...
this.items = [
      {
        label: this.propertiesNameService.getValueFromProperties('home'),//Here is empty also if 'home' is a property with value
      },

      }

所以文本为空,我看不懂:

我的html页面是:

<p-menubar [model]="items" >

</p-menubar>

json文件是:

{
    "dog": "dog",
    "home": "Home",
}

任何人都可以帮助您理解为什么标签为空?

angular angular8 primeng menuitem angular-services
1个回答
0
投票

id属性在哪里?函数接受“哈希”属性this.propertiesName [id]; => this.propertiesName [hash]

© www.soinside.com 2019 - 2024. All rights reserved.