angularjs - Update Multiple selection dropdown list for a single data in a table -
i have list of students each 1 of them can assign roles them in multiselect dropdown list, buut when select roles 1 or 2 changes students in table, each student indivisual if assign role assistant student should one.
<html ng-app="myapp"> <div ng-controller="mycontroller"> <tbody> <tr ng-repeat="s in slist"> <td width="33%">{{s}}</td> <td width="33%"> <div ng-dropdown-multiselect="" extra-settings="dropdownsetting" options="categories" selected-model="categoriesselected" checkboxes="true"> </div> <button type="submit" class="btn btn-primary">submit</button> </td> </tr> </tbody> </div> <script src="../../javascript/lodash.js"></script> <script src="../../javascript/angular.js"></script> <script src="../../javascript/angularjs-dropdown-multiselect.js"></script> <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> <script src="../../javascript/angularcontrollers/controllers.js"></script> <script src="../../javascript/ui-bootstrap-tpls-1.3.3.js"></script> </html>
this controller have pasted part related multidropdownlist
var app = angular.module('myapp', ['angularjs-dropdown-multiselect']); app.controller('multiselectdropdown', ['$scope', '$http', function ($scope, $http) { //loading data table var urlbase = '../myhandler.ashx'; this.getslist = function () { $http.get(urlbase, { params: { plug: "myclassname", cmd: "mymethodname" } }) .success(function (students) { $scope.slist = students; }) .error(function (error) { $scope.status = 'unable load customer data: ' + error.message; }); } this.getslist(); //define object $scope.categoriesselected = []; $scope.categories = []; $scope.dropdownsetting = { scrollable: true, scrollableheight : '200px' } //fetch data database show in multiselect dropdown $http.get('/home/getcategories').then(function (data) { angular.foreach(data.data, function (value, index) { $scope.categories.push({ id: value.categoryid, label: value.categoryname }); }); }) //post or submit selected items multiselect dropdown server $scope.submittedcategories = []; $scope.submitdata = function () { var categoryids = []; angular.foreach($scope.categoriesselected, function (value, index) { categoryids.push(value.id); }); var data = { categoryids: categoryids }; $http({ method: "post", url: "/home/savedata", data:json.stringify(data) }).then(function (data) { $scope.submittedcategories = data.data; }, function (error) { alert('error'); }) } }])
this problem: if select options in dropdownlist changes record in table. how can make changes student want?
thanks
all dropdown seem share same model
selected-model="categoriesselected"
you have use own list each student, e.g.
selected-model="s.categoriesselected"
which have initialize each student
Comments
Post a Comment