2016-09-17 3 views
0

ブロックをドラッグすると、ポップアップウィンドウに人の名前のリストを作成したいと思います。私はユーザーのリストを持っていますが、リストを作成する方法を知らないので、助けてください。アングルでリストを行う方法

マイ角度モジュールとコントローラ

var app = angular.module('DentalEthereumApp', ['ngMaterial', 'ngDraggable']); 
    app.controller('MainCtrl', function ($scope) { 
    $scope.cad_users = []; 
    var modes = ["doctor","delivery","digitize","cad","mill","patient"]; 
    function guys(mode_index) { 
     $.ajax({ 
     type:"GET", 
     url: "/"+modes[mode_index]+"_users", 
     dataType: 'json', 
     success: function(result){ 
      $scope.current_guys = result; 
      alert(JSON.stringify(result)); 
     } 
     }) 
    }; 

    var mill_users = []; 
    var design_users = []; 
    var digitize_users = []; 
    var doctor_users = []; 
    var patient_users = []; 

    $scope.positions = []; 
    $scope.current_guys = []; 
    $scope.centerAnchor = true; 
    $scope.toggleCenterAnchor = function() { 
     $scope.centerAnchor = !$scope.centerAnchor 
    } 
    $scope.Math = Math; 
    var modes = ["doctor","delivery","digitize","cad","mill","patient"]; 
    $scope.parts = ["doctor","delivery","digitize","cad","mill","patient"]; 
    $scope.angles = [-60,0,60,120,180,240,300]; 
    $scope.centerX_lg = 400; 
    $scope.centerY_lg = 270; 
    $scope.radius_lg = 250; 
    $scope.lists = [[{name: 'Заказ 1'}, {name: 'Заказ 2'},{name: 'Заказ 3'},{name: 'Заказ 4'},{name: 'Заказ 5'},{name: 'Заказ 6'},{name: 'Заказ 7'}],[],[],[],[],[]]; 
    $scope.dropSuccess = function(index,listData,event){ 
     $scope.lists[index].push(listData); 
     var obj = {data: listData,mode: $scope.parts[index]}; 
     $scope.positions.push(obj); 
     guys(index); 
     //!!!!Ethereum action 
    } 
    $scope.dragSuccess = function(index,listData,event){ 
     var indexDel= $scope.lists[index].indexOf(listData); 
     if (indexDel>-1) { 
      $scope.lists[index].splice(indexDel,1); 
     } 
    } 

マイビュー、HTMLドキュメント

<div id="contract"> 
     <br><br> 
     <table width="100%"> 
      <tr ng-repeat="position in positions"> 
       <td>{{position}}</td> 
      </tr> 
     </table> 
    </div> 
    <div ng-repeat="index in [0,1,2,3,4,5]"> 
     <div style="position:absolute; 
     width:200px; height:200px; border-radius:10%; 
     background-color:#CCC; 
     top: {{centerY_lg+Math.floor(radius_lg*Math.sin(3.14*angles[index]/180))}}px; 
     left:{{centerX_lg+Math.floor(radius_lg*Math.cos(3.14*angles[index]/180))}}px; 
     " ng-drop="true" ng-drop-success="dropSuccess(index,$data,$event)"> 

     <h3 style="position:absolute;top:2px;">{{parts[index]}}</h3> 

     <div class="ng-drag" ng-repeat="listItem in lists[index]" ng-drag="true" ng-drag-data="listItem" ng-drag-success="dragSuccess(index,$data,$event)"> 
      {{listItem.name}} 
     </div> 

     </div> 
    </div> 
    <div class="contract"> 
     <md-button ng-click="checkBalance()"> 
      Test 
     </md-button> 
    </div> 

私はドラッグすると、私はポップアップウィンドウを取得しますが、名前の順序付きリストを必要とする

私はthis ありがとうございます。あなたがループに必要success:

インサイド

答えて

0

は結果トラフ、必要な属性のみを返します。ここに例があります。

var names = ""; 
result.forEach(function(object, index, array) { 
    names =+ " " + object.name; 
}); 

alert(names); 
関連する問題