在其他视图

时间:2017-04-13 16:59:07

标签: angularjs ionic-framework

我有按钮提交的复选框列表,当我点击提交时,我必须在其他视图表中获取所有选中的值。我找到了很多答案,但是他们都建议在同一个视图中获取值,但我需要在其他视图中获取值(ajoutFactAdmin2),我该怎么做呢。这是代码:

ajoutFactAdmin2.html

<div class="row" ng-repeat="x in namesF3">

          <div class="col"><input type="checkbox" name="" ng-modal="x.selected" ng-checked="exist(x)" ng-click="toggleSelection(x)" ng-true-value="'{{x.CodeEnvoiColis}}'" ng-false-value="''" id="'{{x.CodeEnvoiColis}}'"></div>
          <div class="col" >{{x.CodeEnvoiColis}}</div>   
          <div class="col" width="20%">{{x.StatutColis}}  </div>
          <div class="col" width="20%">{{x.VilleDestColis}}</div> 

</div>

<div class="selectedcontent">
            <h3> Selected Names </h3>
            <p ng-repeat = "selectedName in selected"> {{selectedName.CodeEnvoiColis}} </p>
</div>
          <a class="button button-info"   ng-click="toggleSelection(x)"  href="#/ajoutFactAdmin2" style="background-color:#1627C0;float: right;">Ajouter</a> 

app.js:

 $scope.selected = [];
           $scope.namesF3 = [];
          $scope.exist = function(item){
            return $scope.selected.indexOf(item) > -1;
          }

          $scope.toggleSelection = function(item){
             var x = [];
            var idx = $scope.selected.indexOf(item);
            if(idx > -1){
                 $scope.selected.splice(idx, 1);
            }
             else{
                 $scope.selected.push(item);
             }

          }

1 个答案:

答案 0 :(得分:0)

当用户点击提交按钮时,您需要在控制器上调用一个函数并将所有值检查值存储在本地存储中并重定向到下一页,然后控制器必须获取本地存储值并显示在视图页中

你可以从控制器函数做你必须传递数组作为字符串和在下一个控制器获取状态参数值并使用json.parse将字符串转换为对象并在html中显示