2016-09-17 7 views
0

Ich möchte eine Liste von Personen Namen in das Popup-Fenster erstellen, wenn Sie den Block ziehen. Ich habe eine Liste von Benutzern, aber ich weiß nicht, wie man die Liste erstellt, bitte helfen Sie.Angular, Aufgabenliste in Allert

Mein Winkelmodul und Controller-

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); 
     } 
    } 

Meine Ansicht, html doc

<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> 

Wenn ich ziehe, erhalte ich ein Pop-up-Fenster, muß aber eine geordnete Liste von Namen

Ich habe this Danke.

Antwort

0

Im Inneren des success:

Sie Schleife müssen Trog die Ergebnisse und geben nur die Attribute, die Sie benötigen. Hier ist ein Beispiel.

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

alert(names); 
Verwandte Themen