Angularjs材料或angularjs店多选择在Web服务下拉数据 [英] Angularjs material or angularjs store multiple select dropdown data in webservice

查看:162
本文介绍了Angularjs材料或angularjs店多选择在Web服务下拉数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我采用了棱角分明的材料,我被困在多选下拉列表,在这里我选择多个选项和NG-改变我打电话的功能,这将让每一个选项的ID,我会比较API ID,但正如我选择它会提供功能数据,如
在第一个选项的选择
123456
在第二个选项的选择
123456,456231

I am using Angular material and I am stuck on multi selection dropdown , where I was selecting more than one options and on ng-change I am calling function which will get id of every option and I will compare API id but As I select it will provide data in function like In first option selection 123456 In second option selection 123456,456231

在第三个选项的选择
123456,456231,471258

In Third option selection 123456,456231,471258

所以每当我比较它去的条件内只有一次,而不是更多,甚至我试图分裂它给出了错误,什么也不做。

so whenever I do compare It goes inside the condition only once and not more even I tried to split It gives error and do 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 to handle this situation, if anyone have experience and very well Please let me know.

谢谢
Shivam

Thanks Shivam

推荐答案

我已经创建了codePEN你在这里你可以看到价值每一次改变
因为我不知道你的数据格式,我用了一个演示有一个

I have created Codepen for you where you can see the value changing each time As I dont know you data format I used a demo one

HTML

<div ng-controller="AppCtrl as ctrl" class="md-padding selectdemoBasicUsage" ng-app="MyApp">
  <div>
    <h1 class="md-title">Enter an 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

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的工作液
HTTP://$c$cpen.io/anon/pen/WvygLZ

这篇关于Angularjs材料或angularjs店多选择在Web服务下拉数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆