Javascript 选择在angularjs中传递未定义值的下拉列表?

Javascript 选择在angularjs中传递未定义值的下拉列表?,javascript,jquery,angularjs,Javascript,Jquery,Angularjs,这里我在复选框列表中选中了“三星Galaxy S6”。选中三星Galaxy S6后会出现一个下拉列表。如果在提交后的下拉列表中选择三星Galaxy S6的20%平坦度,我应该在三星Galaxy S6提供id de34575上获得20%平坦度。这里我获得了未定义的值。我在下面添加了我的代码 功能测试1控制器($scope){ var storeid=window.localStorage.getItem(“storeid”); var serverData=[“三星Galaxy Note”、“三

这里我在复选框列表中选中了“三星Galaxy S6”。选中三星Galaxy S6后会出现一个下拉列表。如果在提交后的下拉列表中选择三星Galaxy S6的20%平坦度,我应该在三星Galaxy S6提供id de34575上获得20%平坦度。这里我获得了未定义的值。我在下面添加了我的代码

功能测试1控制器($scope){
var storeid=window.localStorage.getItem(“storeid”);
var serverData=[“三星Galaxy Note”、“三星Galaxy S6”、“三星Galaxy Avant”、“三星Galaxy Young”];
$scope.items=[];

对于(var i=0;i角度

function Test1Controller($scope) {
  var storeid = window.localStorage.getItem("storeid");
    var serverData = ["Samsung Galaxy Note", "Samsung Galaxy S6", "Samsung Galaxy Avant","Samsung Galaxy Young"];
    $scope.items= [] ;

    for(var i=0;i<serverData.length;i++)
    {
        var modal = {
        name:serverData[i],
        selected:false
        };        
        $scope.items.push(modal);        
    }
    //----------------------------Our Shop Offers----------------------------------------
    $scope.offers = [
    {
        id: "as23456",
        Store: "samsung",
        Offer_message:"1500rs off",
        modalname: "Samsung Galaxy Young"       

    },{
        id: "de34575",
        Store: "samsung",
        Offer_message:"20% Flat on Samsung Galaxy S6",
        modalname: "Samsung Galaxy S6"       

    },
    ]
    //-----------------------------------------------------------------------------------
     $scope.check = function()

     {


         var checkedItems = [];
         console.log($scope.offerSelected)
            for(var i=0;i<$scope.items.length;i++)
            {
                  if($scope.items[i].selected){
                      checkedItems.push($scope.items[i].name);
                    }
            }
              console.log(checkedItems) ; 
     }
$scope.selection = [];

      $scope.toggleSelection = function toggleSelection(item) {
$scope.gotOffers=[];
      var idx = $scope.selection.indexOf(item);

      // is currently selected
      if (idx > -1) {
        $scope.selection.splice(idx, 1);
      }

      // is newly selected
      else {
        $scope.selection.push(item);
      }

        for(var i=0;i<$scope.selection.length;i++){
          for(var j=0;j<$scope.offers.length;j++){
            console.log($scope.selection[i].name  +"   "+ $scope.offers[j].modalname)
            if( $scope.selection[i].name  == $scope.offers[j].modalname){
              var idx = $scope.gotOffers.indexOf($scope.offers[j].Offer_message);
              if(idx == -1){
                console.log("inside idx")
                $scope.gotOffers.push($scope.offers[j]);
              }

            }
          }

        }
        console.log($scope.offers);

    };


}
功能测试1控制器($scope){
var storeid=window.localStorage.getItem(“storeid”);
var serverData=[“三星Galaxy Note”、“三星Galaxy S6”、“三星Galaxy Avant”、“三星Galaxy Young”];
$scope.items=[];

对于(var i=0;i.检查该小提琴。假设我已经选择了三星Galaxy S6。所以我已经按下了如下复选框var selectedvalue=“三星Galaxy S6”;对于(var i=0;i=0 | | null){modal.selected=true;}$scope.items.push(modal)}。当我删除选中的ng时,它不起作用=“selection.indexOf(item)>-1”ng click=“toggleSelection(item)”。删除ng click=“toggleSelection(item)”时,复选框checkedIt将不起作用"因为您的优惠功能是基于它的。请参考。只是为了得到一个建议,为什么您不使用单选按钮来代替复选框??在这里,我想在复选框列表中按下选定值。我的小提琴请参考。我想这就是您试图实现的??如何显示已选中的值在该复选框列表中?选中此小提琴。当我添加ng checked=“selection.indexOf(item)>-1”ng click=“toggleSelection(item)”此行不起作用
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.min.js"></script>

<div ng-app>
  <div ng-controller="Test1Controller" >
    <div ng-repeat="item in items">
      <input type="checkbox" ng-model="item.selected"  ng-checked="selection.indexOf(item) > -1" ng-click="toggleSelection(item)"/> {{item.name}}
    </div>
    <select ng-show="gotOffers.length > 0" ng-model="offerSelected">
      <option ng-repeat="offer in gotOffers"  value="{{offer.id}}">{{offer.Offer_message}}</option>
    </select>

      <input type="button" name="submit" value="submit" ng-click="check()"/>
  </div>
</div>