2017-09-13 38 views
1

我有我通过函数建立ngStyle一个组成部分,它的工作原理所有样式除溢出-Y,我不知道它实际上是设置本身以及任何想法?集ngStyle使用Angular2

onChangeFilterClientes(obj:any):any[]{   
    return this.clientes.filter(c => c.Nombre.toString().toLowerCase().indexOf(obj.query)>-1);   

    } 

我的组件上的功能:

interface IOpcionesListaAutocomplete { 
    width: number; 
    height: number; 
    isOverflowY: boolean; 
} 

export class OpcionesListaAutocomplete implements IOpcionesListaAutocomplete { 
    width: number; 
    height: number; 
    isOverflowY: boolean; 
    constructor() { } 
} 

@Input() 
opcionesLista: IOpcionesListaAutocomplete = { 
    width: 550, 
    height: 150, 
    isOverflowY: true 
}; 


addStylesLista(){ 
    let styles= { 
     'heigth.px':this.opcionesLista.height, 
     'width.px':this.opcionesLista.width, 
     'overflow-y': this.opcionesLista.isOverflowY? 'auto': 'hidden' 
    }; 
    return styles; 
} 

所有样式工作正常,除了溢出。

回答

0

尝试把问号和变量之间的空间。

'overflow-y': this.opcionesLista.isOverflowY ? 'auto': 'hidden' 
0

除了@采访助手的回答,注意到了addStylesLista()方法的另一个错字的'height.px'(在这个问题这是'heigth.px')。

0

这很可能是由于覆盖到样式规格别的地方?尝试添加!important它:

'overflow-y': (this.opcionesLista.isOverflowY? 'auto': 'hidden') + ' !important'