Twitter bootstrap ng2引导程序中的字体无法显示Angular 2中的项目
更新:它现在支持嵌套属性Twitter bootstrap ng2引导程序中的字体无法显示Angular 2中的项目,twitter-bootstrap,angular,ng2-bootstrap,Twitter Bootstrap,Angular,Ng2 Bootstrap,更新:它现在支持嵌套属性 我在Angular 2中使用 我正在试着用打字机 示例代码 private statesComplex:Array<any> = [ {id: 1, name: 'Alabama'}, {id: 2, name: 'Alaska'}, {id: 3, name: 'Arizona'}]; 私有状态复杂:数组=[ {id:1,名称:'Alabama'},{id:2,名称:'Alaska'},{id:3,名称:'Arizona'}]; 及 运行
我在Angular 2中使用 我正在试着用打字机 示例代码
private statesComplex:Array<any> = [
{id: 1, name: 'Alabama'}, {id: 2, name: 'Alaska'}, {id: 3, name: 'Arizona'}];
私有状态复杂:数组=[
{id:1,名称:'Alabama'},{id:2,名称:'Alaska'},{id:3,名称:'Arizona'}];
及
运行良好
但是当我试图改变数据格式时
private statesComplex:Array<any> = [
{id: 1, profile: {name: 'Alabama', email: '111'}}, {id: 2, profile: {name: 'Alaska', email: '222'}}, {id: 3, profile: {name: 'Arizona', email: '333'}}];
私有状态复杂:数组=[
{id:1,个人资料:{name:'Alabama',email:'111'},{id:2,个人资料:{name:'Alaska',email:'222'},{id:3,个人资料:{name:'Arizona',email:'333'}];
和使用
<input [(ngModel)]="selected"
[typeahead]="statesComplex"
(typeaheadOnSelect)="typeaheadOnSelect($event)"
[typeaheadOptionField]="'profile.name'"
class="form-control">
它不起作用。我认为这个问题与typeaheadOptionField有关,但我不知道怎么写
谢谢看起来这种符号不会被识别为子对象的嵌套属性(请参见)。在这种情况下,您可以稍微预处理数据。可能通过实际引入此帮助器属性:
this.statesComplex.forEach(state => state['profile.name'] = state.profile.name);
它将为所有对象添加新的
profile.name
property,这样typeahead就可以按预期工作了。哇,这太神奇了,您已经阅读了源代码!现在可以了!如果可能的话,我建议作者支持嵌套属性。非常感谢你!
this.statesComplex.forEach(state => state['profile.name'] = state.profile.name);