I am facing an issue with the anular-ui-bootstrap modal directive. Am using the angular's ui-select component in my app as a replacement for the html select. This ui-select is working fine in any page it is being included. But when i tried to include it in a modal pop up(using ui-bootstrap $modal service), the drop-down is not displaying the options
The issue is reproduced here
angular.module('ui.bootstrap.demo').controller('ModalInstanceCtrl', function ($scope, $modalInstance, items) {
$scope.addresses = [{
"id":1,
"name": "chennai"
}, {
"id":2,
"name": "banglore"
}, {
"id":3,
"name": "madurai"
}];
});
<div class="modal-body">
City
<ui-select ng-model="selAddress">
<ui-select-match placeholder="Choose an address">{{$select.selected.name}}</ui-select-match>
<ui-select-choices repeat="address in addresses track by $index" refresh-delay="0">
<div ng-bind-html="address.a | highlight: $select.search"></div>
</ui-select-choices>
</ui-select>
Selected: <b>{{ selAddress }}</b>
</div>
Any help would be much appreciated. Thanks in advance.
ui-select is the AngularJS-native version of Select2 and Selectize. It is an hybrid between a text box and a select. Features include: Search, Select, and Multi-select. Themes: Bootstrap, Select2 and Selectize.
$uibModal is a service to create modal windows. It has an open method, that will return a modal instance. var modalInstance = $uibModal.
Bootstrap UI is a consistent library of design patterns for building beautiful and intuitive web apps on Bootstrap, the most popular CSS framework on the web.
Mobile Angular UI is an open-source framework for developing hybrid mobile apps. Mobile Angular UI makes use of Twitter Bootstrap and AngularJS that helps to create attractive HTML5 hybrid mobile and desktop apps.
I've got the same problem, to resolve it I just install select2 https://www.npmjs.com/package/select2 and i import on my component who use ui-select like this:
import uiSelect from 'ui-select'
import 'ui-select/dist/select.min.css'
import 'select2/select2.css'
const myModule = angular.module("myModule", [ uiSelect ]);
<ui-select
multiple
ng-model="$ctrl.personSelected"
close-on-select="false"
theme="select2"
style="width:100%"
class="form-group"
>
<ui-select-match>{{$item}}</ui-select-match>
<ui-select-choices repeat="person in $ctrl.listPerson">
{{ person.name }}
</ui-select-choices>
</ui-select>
I ran into this (or something similar) with ngDialog. I fixed my problem by adding a ng-hide
attribute like so:
<ui-select-choices repeat="..." ng-hide="!$select.open">
This fixed the problem that I had where select-choices
was given a ng-hide
empty attribute by the component for some reason internally when in a dialog. Hope this helps you workaround this issue as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With