Skip to content

Commit

Permalink
but fox on list formatter not applying and dropdown positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
allenhwkim committed Feb 11, 2017
1 parent f091f04 commit b622271
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/ng2-auto-complete.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,9 @@ export class Ng2AutoCompleteComponent implements OnInit {
getFormattedList(data: any): string {
let formatted;
let formatter = this.listFormatter || '(id) value';
if (typeof data !== 'object') {
if (typeof formatter === 'function') {
formatted = formatter.apply(this, [data]);
} else if (typeof data !== 'object') {
formatted = data;
} else if (typeof formatter === 'string') {
formatted = formatter;
Expand All @@ -281,8 +283,6 @@ export class Ng2AutoCompleteComponent implements OnInit {
formatted = formatted.replace(key, data[key]);
});
}
} else if (typeof formatter === 'function') {
formatted = formatter.apply(this, [data]);
}
return formatted;
}
Expand Down
14 changes: 1 addition & 13 deletions src/ng2-auto-complete.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export class Ng2AutoCompleteDirective implements OnInit {
let thisInputElBCR = this.inputEl.getBoundingClientRect();
let closeToBottom = thisInputElBCR.bottom + 100 > window.innerHeight;

this.acDropdownEl.style.width = thisElBCR.width + "px";
this.acDropdownEl.style.width = thisInputElBCR.width + "px";
this.acDropdownEl.style.position = "absolute";
this.acDropdownEl.style.zIndex = "1";
this.acDropdownEl.style.left = "0";
Expand All @@ -195,10 +195,8 @@ export class Ng2AutoCompleteDirective implements OnInit {
if (val && typeof val === "object") {
let displayVal;
if (this.displayPropertyName) {
console.log(1);
displayVal = val[this.displayPropertyName];
} else if (this.listFormatter) {
console.log(2);
displayVal = val[this.listFormatter];
} else {
console.log(3, val.value);
Expand All @@ -211,7 +209,6 @@ export class Ng2AutoCompleteDirective implements OnInit {
return val;
}


componentInputChanged = (val: string) => {
if (this.acceptUserInput !== false) {
this.inputEl.value = val;
Expand Down Expand Up @@ -245,15 +242,6 @@ export class Ng2AutoCompleteDirective implements OnInit {
this.hideAutoCompleteDropdown();
};

// private elementIn(el: Node, containerEl: Node): boolean {
// while (el = el.parentNode) {
// if (el === containerEl) {
// return true;
// }
// }
// return false;
// }

private keydownEventHandler = (evt: any) => {
if (this.componentRef) {
let component = <Ng2AutoCompleteComponent>this.componentRef.instance;
Expand Down

0 comments on commit b622271

Please sign in to comment.