简体   繁体   English

选择下拉项 object 时 md-autocomplete 显示 [Object Object]

[英]md-autocomplete when selecting a dropdown item object it says [Object Object]

        <md-autocomplete
            required
            md-input-class="OfficialClass"
            md-selected-item="selectedOfficial"
            md-search-text="searchText"
            md-items="item in findOfficials(searchText)"
            md-item-text="item.user.display_value"
            md-no-cache="true"
            md-search-text-change="searchTextChange(searchText)"
            md-selected-item-change="selectedItemChange(item.name.value)"
            md-floating-label="New Official"
            md-min-length="3"
            md-autofocus md-autoselect>
          <md-item-template>
            <span md-highlight-text="searchText" md-highlight-flags="^i"> 
             {{item.name.display_value}} - {{item.email.display_value}}</span>
          </md-item-template>
        </md-autocomplete>
      </div> 
      <md-dialog-actions>
        <md-button ng-disable="required" class="md-primary md-raised" aria-label="Submit" ng- 
          click="submitO(selectedOfficial)">Submit Request</md-button>
       \</md-dialog-actions>

I have this autocomplete and right now selectedOfficial returns [Object Object] in my drop down once I select an option.我有这个自动完成,现在 selectedOfficial 在我的下拉列表中返回 [Object Object] 一旦我 select 一个选项。 The drop down options as of now display perfectly, the name and email. But once I select the user, I want only the users name to show as the final selected option.截至目前,下拉选项显示完美,名称和 email。但是一旦我 select 用户,我只希望用户名显示为最终选择的选项。 Right now I am using selectedOfficial in my method submitO because it has an associated sys_ID with it that i need to reference.现在我在我的方法 submitO 中使用 selectedOfficial,因为它有一个关联的 sys_ID,我需要引用它。

so the selectedOfficial object looks as so:所以 selectedOfficial object 看起来是这样的:

{
    "sys_id": {
        "display_value": "12345",
        "value": "1234"
    },
    "name": {
        "display_value": "joe bob",
        "value": "joe bob"
    },
    "email": {
        "display_value": "joebob@email.com",
        "value": "joebob@email.com"
    }
}

right now when I hit submitO, it references selectedOfficial and I use the sys_id for a call that I need.现在,当我点击 submitO 时,它引用了 selectedOfficial 并且我使用 sys_id 进行我需要的调用。

so the question here is, how do I make the dropdown say the display name所以这里的问题是,如何让下拉菜单显示显示名称

I tried md-selected-item="selectedOfficial.name.value" and it still says [Object Object] I even tried item.name.value in the md-select and it still does [object object]我试过 md-selected-item="selectedOfficial.name.value" 但它仍然显示 [Object Object] 我什至在 md-select 中尝试了 item.name.value 并且它仍然显示 [object object]

is there some sort of hacky way I can make the dropdown say the objects name value???是否有某种 hacky 方法可以让下拉菜单显示对象名称值??? I am very stuck and need some help on this its the last piece of the puzzle that I cannot figure out.我很困惑,需要一些帮助,这是我无法弄清楚的最后一块拼图。 thanks in advance提前致谢

md-item-text="item.user.display_value" should be item.name.display_value md-item-text="item.user.display_value"应该是item.name.display_value

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM