Angular,如何在allert中列出

时间:2016-09-17 15:06:14

标签: javascript ruby-on-rails angularjs

我想在拖动块时在弹出窗口中列出人名。我有一个用户列表,但不知道如何列出,请帮忙。

我的角度模块和控制器

 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 感谢。

1 个答案:

答案 0 :(得分:0)

success:

您需要循环显示结果并仅返回所需的属性。这是一个例子。

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

alert(names);