Reputation: 4886
can anyone please tell me whether there is any plugin in angular, bootstrap for add remove modal component like as shown below in the picture
Upvotes: 2
Views: 2633
Reputation: 20741
You can use Angularjs based ngListSelect plugin for achieving this
simply import
minified
<script type="text/javascript" src="https://cdn.rawgit.com/nidhishkrishnan/ngListSelect/master/ngListSelect.min.js"></script>
non-minified
<script type="text/javascript" src="https://cdn.rawgit.com/nidhishkrishnan/ngListSelect/master/ngListSelect.js"></script>
Add ngListSelect
as a dependency to your app
angular.module('your-app', ['ngListSelect']);
and use the ngListSelect
directive in your template like as shown below
<ng-list-select selected-list="selectedList" key="name" available-list="availableList" button-style="olive" panel-style="olive"></ng-list-select>
Upvotes: 4
Reputation: 4079
I don't know a ready-to-intstall module with bootstrap styling, but the basic implementation is quite simple: http://jsfiddle.net/andytjoslin/aeSaJ/3/
<div ng-app>
<div ng-controller="fling">
<select multiple="true" ng-model="selected" ng-options="item for item in selectedItems">
</select>
_________________
<select multiple="true" ng-model="available" ng-options="item for item in availableItems">
</select>
<br />
<button ng-click="moveItem(selected[0], selectedItems, availableItems)">
Move sel -->
</button>
<button ng-click="moveItem(available[0], availableItems, selectedItems)">
<-- Move sel
</button>
<br />
<button ng-click="moveAll(selectedItems, availableItems)">
Move all -->
</button>
<button ng-click="moveAll(availableItems, selectedItems)">
<-- Move all
</button>
{{selectedItems}}
{{availableItems}}
</div>
</div>
function fling($scope) {
$scope.moveItem = function(item, from, to) {
var idx=from.indexOf(item);
if (idx != -1) {
from.splice(idx, 1);
to.push(item);
}
};
$scope.moveAll = function(from, to) {
angular.forEach(from, function(item) {
to.push(item);
});
from.length = 0;
};
$scope.selectedItems = ['a','b','c'];
$scope.availableItems = [1,2,3];
}
it should be easy to add bootstrap classes here.
Upvotes: 2