AngularStrap Typeahead随机选择显示值而不是模型值

时间:2016-01-27 15:21:51

标签: angularjs angular-strap

我在几个下拉列表中使用AngularStrap的Typeahead指令,有时,显示值显示为所选值。

例如,如果我想在输入字段中仅显示数字作为选定值,有时会选择数字和描述。以下是相关代码:

<input type="text" class="form-control" 
        bs-typeahead
        bs-options="x.num as (x.num > 0 ? x.num + '. ' + x.Description :  '')for x 
                   in crc.xList | orderBy: 'x.num'" 
        data-autoSelect="true"
        data-limit="15"
        ng-model="crc.newNum"
        ng-model-options="{ debounce: 500 }"
        ng-change="crc.getNumInfo(false, true)" />

任何帮助将不胜感激 - 谢谢!

1 个答案:

答案 0 :(得分:0)

我认为这是因为(x.num > 0 ? x.num + '. ' + x.Description : ''),我认为当x.num为0时,angular会替换空字符串,您是否可以尝试执行(x.num > 0 ? x.num + '. ' + x.Description : 'test')并查看它是否已修复它?