javascript - Angularjs material or angularjs store multiple select dropdown data in webservice -


i using angular material , stuck on multi selection dropdown , selecting more 1 options , on ng-change calling function id of every option , compare api id select provide data in function in first option selection 123456 in second option selection 123456,456231

in third option selection 123456,456231,471258

so whenever compare goes inside condition once , not more tried split gives error , nothing.

<md-select ng-model="$parent.follower" placeholder="select person" multiple="true" ng-change="getfollowers(follower)">                   <md-option ng-repeat="follower in followers" value="{{follower.id}}"> {{follower.full_name}}</md-option>    </md-select> 

so let me know how handle situation, if have experience , please let me know.

thanks shivam

i have created codepen can see value changing each time dont know data format used demo one

html

<div ng-controller="appctrl ctrl" class="md-padding selectdemobasicusage" ng-app="myapp">   <div>     <h1 class="md-title">enter address</h1>     <div layout="row">       <md-input-container>         <label>street name</label>         <input type="text">       </md-input-container>       <md-input-container>         <label>city</label>         <input type="text">       </md-input-container>       <md-select placeholder="state" ng-model="ctrl.userstate" multiple="true" ng-change='changevalue(ctrl.userstate)'>         <md-option ng-repeat="state in ctrl.states" value="{{state.abbrev}}">{{state.abbrev}}</md-option>       </md-select>     </div>   </div> </div> 

angularjs code

      'use strict';       angular           .module('myapp')           .controller('appctrl', function($scope,$http) {             this.userstate = '';             this.states = ('al ak az ar ca co ct de fl ga hi id il in ia ks ky la me md ma mi mn ms ' +                 'mo mt ne nv nh nj nm ny nc nd oh ok or pa ri sc sd tn tx ut vt va wa wv wi ' +                 'wy').split(' ').map(function (state) { return { abbrev: state }; });      $scope.changevalue=function(value){         console.log(value);      $http.post(//url).then(function(response){ //handle response here      });   }       }); 

codepen working solution http://codepen.io/anon/pen/wvyglz


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -