Skip to content

Commit

Permalink
fix issue#28
Browse files Browse the repository at this point in the history
  • Loading branch information
NileshPatel17 committed Apr 28, 2018
1 parent 6068780 commit 236c69b
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 17 deletions.
11 changes: 3 additions & 8 deletions .angular-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,15 @@
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"assets": ["assets", "favicon.ico"],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"styles.scss"
],
"prefix": "ng",
"styles": ["styles.scss"],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ng-multiselect-dropdown",
"version": "0.1.6",
"version": "0.1.7",
"private": true,
"description": "Angular Multi-Select Dropdown",
"author": "Nilesh Patel",
Expand Down
4 changes: 2 additions & 2 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';

import { TabsModule, ButtonsModule } from 'ngx-bootstrap';
// import { NgMultiSelectDropDownModule } from '../ng-multiselect-dropdown/src';
import { NgMultiSelectDropDownModule } from 'ng-multiselect-dropdown';
import { NgMultiSelectDropDownModule } from '../ng-multiselect-dropdown/src';
// import { NgMultiSelectDropDownModule } from 'ng-multiselect-dropdown';

import { SelectSectionComponent } from './components/select-section';
import { SampleSectionComponent } from './components/sample-section.component';
Expand Down
8 changes: 7 additions & 1 deletion src/app/components/select/multiple-demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Component, OnInit } from '@angular/core';
export class MultipleDemoComponent implements OnInit {
myForm: FormGroup;
disabled = false;
ShowFilter = false;
ShowFilter = true;
showAll = true;
limitSelection = false;
cities: Array<any> = [];
Expand Down Expand Up @@ -119,7 +119,13 @@ export class MultipleDemoComponent implements OnInit {

onItemSelect(item: any) {
console.log('onItemSelect', item);
console.log('form model', this.myForm.get('city').value);
}
onItemDeSelect(item: any) {
console.log('onItem DeSelect', item);
console.log('form model', this.myForm.get('city').value);
}

onSelectAll(items: any) {
console.log('onSelectAll', items);
}
Expand Down
1 change: 1 addition & 0 deletions src/app/components/select/single-demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export class SingleDemoComponent implements OnInit {

onItemSelect(item: any) {
console.log('onItemSelect', item);
console.log('selectedItem', this.selectedItem);
}

toggleCloseDropdownSelection() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div tabindex="=0" (blur)="onTouched()" class="multiselect-dropdown" (clickOutside)="closeDropdown()">
<div [class.disabled]="disabled">
<span tabindex="-1" class="dropdown-btn" (click)="toggleDropdown($event)">
<span *ngIf="selectedItems.length == 0">{{placeholder}}</span>
<span *ngIf="selectedItems.length == 0">{{_placeholder}}</span>
<span class="selected-item" *ngFor="let item of selectedItems;trackBy: trackByFn;let k = index" [hidden]="k > _settings.itemsShowLimit-1">
{{item.text}}
<a style="padding-top:2px;padding-left:2px;color:white" (click)="onItemClick($event,item)">x</a>
Expand Down
15 changes: 11 additions & 4 deletions src/ng-multiselect-dropdown/src/multiselect.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class MultiSelectComponent implements ControlValueAccessor {
public _data: Array<ListItem> = [];
public selectedItems: Array<ListItem> = [];
public isDropdownOpen = false;

_placeholder: string = 'Select';
filter: ListItem = new ListItem(this.data);
defaultSettings: DropdownSettings = {
singleSelection: false,
Expand All @@ -72,7 +72,14 @@ export class MultiSelectComponent implements ControlValueAccessor {
closeDropDownOnSelection: false
};

@Input() placeholder = 'Select';
@Input()
public set placeholder(value: string) {
if (value) {
this._placeholder = value;
} else {
this._placeholder = 'Select';
}
}
@Input() disabled = false;

@Input()
Expand Down Expand Up @@ -236,7 +243,7 @@ export class MultiSelectComponent implements ControlValueAccessor {
} else {
this.selectedItems.push(item);
}
// this.onChangeCallback(this.emittedValue(this.selectedItems));
this.onChangeCallback(this.emittedValue(this.selectedItems));
this.onSelect.emit(this.emittedValue(item));
}

Expand All @@ -246,7 +253,7 @@ export class MultiSelectComponent implements ControlValueAccessor {
this.selectedItems.splice(this.selectedItems.indexOf(item), 1);
}
});
// this.onChangeCallback(this.emittedValue(this.selectedItems));
this.onChangeCallback(this.emittedValue(this.selectedItems));
this.onDeSelect.emit(this.emittedValue(itemSel));
}

Expand Down

0 comments on commit 236c69b

Please sign in to comment.