9

We are moving our existing angular1 project to angular2 and want to replace the existing ui-select component.

I have googled, but couldn't find the ui-select version for angular2.

Has anyone found a better alternative?

imfarhad
  • 172
  • 1
  • 3
  • 10

6 Answers6

2

ng2-select would do some of it. But it does not support dynamic data binding yet.

Actually, almost any of third party plugins implemented for angular is not implemented for angular2.

BinaryButterfly
  • 18,137
  • 13
  • 50
  • 91
asdf_enel_hak
  • 7,474
  • 5
  • 42
  • 84
2

PrimeNG's dropdown or multiselect may help.

http://www.primefaces.org/primeng/#/dropdown

or

http://www.primefaces.org/primeng/#/multiselect

Cagatay Civici
  • 6,406
  • 1
  • 29
  • 34
0

If anyone is migrating to ng2 and needs to run a hybrid application (running both ng1 and ng2 - now called AngularJS and Angular respectively) it is possible to wrap ng1 UI widgets that were not created using ng1 components (like ui-select) for use within ng2 component templates. We've done this successfully with ui-select and it works great. In particular, look at the @Directive annotation binding.

import {Directive, ElementRef, Injector, Input} from '@angular/core';
import {UpgradeComponent} from '@angular/upgrade/static';
import {module, IComponentOptions} from 'angular';

class UiSelectComponent implements IComponentOptions {

  public bindings: any = {
    items: '<',
    model: '<',
    modelProperty: '@',
    placeholder: '@',
    renderProperty: '@',
    selectProperty: '@'
  };
  public template = `
    <ui-select ng-model="$ctrl.model[$ctrl.modelProperty]" class="form-control input-sm" required>
      <ui-select-match placeholder="{{$ctrl.placeholder}}">{{$select.selected[$ctrl.renderProperty]}}</ui-select-match>
      <ui-select-choices repeat="item[$ctrl.selectProperty] as item in $ctrl.items | filter: $select.search">
        {{item[$ctrl.renderProperty]}}
      </ui-select-choices>
    </ui-select>
  `;
}

const selector = 'uiSelectWrapper';
export const UI_SELECT_COMPONENT = 'spinnaker.core.widget.uiSelect.component';
module(UI_SELECT_COMPONENT, []).component(selector, new UiSelectComponent());

@Directive({
  selector: 'ui-select-wrapper'
})
export class UiSelectComponentDirective extends UpgradeComponent {

  @Input()
  public items: any[];

  @Input()
  public model: any;

  @Input()
  public modelProperty: string;

  @Input()
  public placeholder: string;

  @Input()
  public renderProperty: string;

  @Input()
  public selectProperty: string;

  constructor(elementRef: ElementRef, injector: Injector) {
    super(selector, elementRef, injector);
  }
}
icfantv
  • 4,523
  • 7
  • 36
  • 53
  • Link says page not found. Please correct it. "Here is a link to our source" – Sangwin Gawande Nov 07 '17 at 05:33
  • 1
    @SangwinGawande unfortunately, we decided to go with an AngularJS and React hybrid application rather than migrate to Angular so the source was removed. I will update the description to remove that line. I will point out that the Angular docs do (or did) indicate how to do this. – icfantv Dec 18 '17 at 18:47
0

Please check ng-select. It has single select, multi-select, search autocomplete, tags, grouping, and all of above virtual scrolling too. I hope this might help.

Sufiyan Momin
  • 121
  • 1
  • 10
-1

For components developed specifically for Angular 2, see the DropDowns package of Kendo UI for Angular 2. It's still in beta, and feedback is welcome.

Alex Gyoshev
  • 11,929
  • 4
  • 44
  • 74
  • 2
    Just so everyone is aware, Kendo UI is a commercial license and requires you to purchase a license for any other use than some hobby coding. – perry Feb 18 '18 at 23:54
-1

Have you seen ngx-select-ex fork of ng2-select. ngx-select-ex has single select, multiselect, slected, blur event like select2. Please have a look, demo of ngx-select-ex

Sufiyan Momin
  • 121
  • 1
  • 10
  • A link to a solution is welcome, but please ensure your answer is useful without it: [add context around the link](//meta.stackexchange.com/a/8259) so your fellow users will have some idea what it is and why it’s there, then quote the most relevant part of the page you're linking to in case the target page is unavailable. [Answers that are little more than a link may be deleted.](//stackoverflow.com/help/deleted-answers) – geisterfurz007 Feb 21 '18 at 06:11