Arrays 将阵列数据从一个控制器发送到angularjs中的另一个控制器

Arrays 将阵列数据从一个控制器发送到angularjs中的另一个控制器,arrays,angularjs,controller,Arrays,Angularjs,Controller,我将在一个页面中选择图像,并在另一个页面中显示所选的5个图像。在向服务器发送put请求之前,所选图像最初将存储在selected数组中。在显示页面时,我有一个名为“更改图片”的按钮,在选择图像页面中选择5个图像后,我将向服务器发送put请求,这些图像将存储在名为other_media的数组中。如果我单击“更改图片”按钮,它将重定向到选择图像页面(选择的数组将再次为空),已选择显示在plunker结果右侧的图像[意味着我需要将其他_媒体阵列中的数据推送到选定阵列]。我需要准确地显示已选择(发布或放

我将在一个页面中选择图像,并在另一个页面中显示所选的5个图像。在向服务器发送put请求之前,所选图像最初将存储在selected数组中。在显示页面时,我有一个名为“更改图片”的按钮,在选择图像页面中选择5个图像后,我将向服务器发送put请求,这些图像将存储在名为other_media的数组中。如果我单击“更改图片”按钮,它将重定向到选择图像页面(选择的数组将再次为空),已选择显示在plunker结果右侧的图像[意味着我需要将其他_媒体阵列中的数据推送到选定阵列]。我需要准确地显示已选择(发布或放置)的图像
plunker仅是我选择图像的一个页面。 普朗克

如果我像这样使用内部服务,为什么我得到
无法读取未定义的属性“splice”

一个我的网站视频来理解

看看这个。在这个答案中,他们在一个数组中发送一个对象,我需要发送整个数组以存储在另一个数组中,这些数组来自不同的控制器答案使用
服务
。它们只启动一次,并在整个应用程序中保持不变。。在这个答案中,您可以将多个对象推入阵列,并将它们弹出到另一个控制器中。像邮箱一样使用它。你可以发送你想要的任何东西,事实上使用
服务
来访问你应用程序中的所有数据。@ThilakRaj在调用
splice
之前,请检查从一个或另一个
传递到
的内容。为什么
源代码
未定义。
 <div class="row">
  <div class="col-xs-6 col-sm-5 col-md-5">
    <h3 style="text-align: center;text-shadow: 0px 4px 6px;">All Pictures</h3>
    <div class="row" ng-repeat="media in pinMedia">
      <!-- pin.media_id!=media._id || -->
      <div class="col-xs-12 col-sm-12 col-md-5">
        <img ng-src="http://placehold.it/{{images}}" width="200px" />
        <p>{{media.Name}}</p>
        <div class="col-xs-12 col-sm-12 col-md-5">
          <button ng-disabled='limit()' class="btn btn-success" style="border: .0625rem solid transparent;padding: .465rem 1rem;" ng-click="toselected(media)">
            <i class="fa fa-picture-o"></i>
 Set Picture</button >
        </div>
      </div>
    </div>
  </div>
  <div class="col-xs-6 col-sm-5 col-md-5">
    <h3 style="text-align: center;text-shadow: 0px 4px 6px;">Selected Pictures</h3>
    <div ng-repeat="media in selected">
      <!-- pin.media_id==media._id && -->
      <div>
        <img ng-src="http://placehold.it/{{images}}" width="200px" />
        <p>{{media.Name}}</p>
        <div>
          <a class="btn btn-success " style="border: .0625rem solid transparent;padding: .465rem 1rem;" ng-click="tosource(media)">
            <i class="fa fa-picture-o"></i>
 Remove Picture</a>
        </div>
      </div>
    </div>
  </div>
</div>
  <!--I have id in my work. but here we don't have id. i need to save particular object in an selected array to  another array -->

 <button ng-click="setMediaForCurrentPin(selected)" class="btn btn-success" style="margin:50px auto; display:table;">Submit</button>
     $scope.selected = [];

        FromOne2Another = function(source, target, item) {
            target.push(item);
            source.splice(source.indexOf(item), 1);

        }
//this is the starting of code where i send the selected pitures from unselected before put request.
        $scope.toselected = function(item) {
            FromOne2Another($scope.pinMedia, $scope.selected, item);
        }

        $scope.tosource = function(item) {
            FromOne2Another($scope.selected, $scope.pinMedia, item);

        }
//this is the ending of above code
//From here i am trying to get the data from the stored media
          $scope.toSelectedArray=function(item){

            FromOne2Another($scope.other_media, $scope.selected, item);
            console.log($scope.pins);
         }