I have a multi select dropdown list implemented with angular material design and it's working, it loads all the possible options (Categories) and it checks the items selected already.
I want to update database based on select/unselect in this dropdown list. How can I do so?
<md-select ng-model="SelectedItems" multiple>
<md-option ng-repeat="item in Categories">{{item}}</md-option>
</md-select>
check this ng-change directive
It will get you the value in controller as soon as you check/uncheck (function) then call the query function to update the database. Hope it helps.
just take this an example and write your update code with in $scope.onChange function
html
<div ng-controller="MyCtrl" layout layout-align="center center">
<md-select ng-model="myModel" placeholder="Pick" ng-change="onChange(myModel)" >
<md-option value="0">Zero</md-option>
<md-option value="1">One</md-option>
</md-select>
</div>
js
angular.module('MyApp', ['ngMaterial'])
.controller('MyCtrl', function ($scope) {
$scope.onChange = function(k) {
alert(k);
//your code here for storing in db
};
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.