Skip to content

Commit

Permalink
fix(module:input): fix input disabled style bug (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
vthinkxie authored Aug 26, 2017
1 parent 5d666fc commit b7a073c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
16 changes: 8 additions & 8 deletions src/components/input/nz-input.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import {
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';

@Component({
selector: 'nz-input',
selector : 'nz-input',
encapsulation: ViewEncapsulation.None,
template: `
template : `
<span class="ant-input-group-addon" *ngIf="_addOnContentBefore">
<ng-template [ngTemplateOutlet]="_addOnContentBefore">
</ng-template>
Expand Down Expand Up @@ -62,14 +62,14 @@ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
<ng-template [ngTemplateOutlet]="_addOnContentAfter">
</ng-template>
</span>`,
providers: [
providers : [
{
provide: NG_VALUE_ACCESSOR,
provide : NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => NzInputComponent),
multi: true
multi : true
}
],
styleUrls: [
styleUrls : [
'./style/index.less',
'./style/patch.less'
]
Expand Down Expand Up @@ -158,8 +158,8 @@ export class NzInputComponent implements AfterContentInit, ControlValueAccessor

setClassMap(): void {
this._classMap = {
[this._prefixCls+'-'+this._size]: true,
[`${this._prefixCls}-disabled`]: this._disabled
[this._prefixCls + '-' + this._size]: true,
[`${this._prefixCls}-disabled`] : this._disabled
};
}

Expand Down
13 changes: 5 additions & 8 deletions src/components/input/nz-input.directive.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import {
})
export class NzInputDirectiveComponent {
size = 'default';
_disabled = false;
nativeElement: HTMLElement;
@HostBinding(`class.ant-input-disabled`) _disabled = false;

@Input()
get nzSize(): string {
Expand All @@ -35,17 +35,14 @@ export class NzInputDirectiveComponent {
};

set nzDisabled(value: boolean) {
if(value){
this.nativeElement.setAttribute('disabled','');
if (value) {
this._render.setAttribute(this.nativeElement, 'disabled', '');
} else {
this._render.removeAttribute(this.nativeElement, 'disabled');
}
this._disabled = value;
}

@HostBinding(`class.ant-input-disabled`)
get setDisabledClass(): boolean {
return this._disabled === true;
};

@HostBinding(`class.ant-input`) _nzInput = true;


Expand Down

0 comments on commit b7a073c

Please sign in to comment.