2016-10-19 6 views
2

私はAPIコントローラを参照する配列を持っており、応答ステータスは200です。配列を格納しているうちに、 。ロードされた配列は、.netアプリケーションのng-optionsのangleディレクティブにバインドされていません

しかし、ng-optionsディレクティブを使用してaspxとバインドしようとすると、ドロップダウンに値が設定されません。

角度コード:

 ERMApp.controller("CascadeDeleteController", 
function ($scope, $http, $sce, $rootScope, commondatafactory, academicsetupfactory) { 

    $rootScope.loading = true; 
    $scope.successMessage = ""; 
    $scope.successMessageHtml = ""; 
    $scope.errorMessage = ""; 
    $scope.errorMessageHtml = ""; 
    $scope.errorLabelStyle = { color: 'red' }; 
    $scope.PrimaryTables = []; 
    $scope.PrimaryTableNames = []; 

    $scope.newCascade = Object.create(null); 
    $scope.showForm = true; 

    $scope.reset = function() { 
     $scope.newCascade = Object.create(null); 
    }; 

    $scope.validation = function() { 
     $scope.successMessage = ""; 
     $scope.successMessageHtml = ""; 
     $scope.errorMessage = ""; 
     $scope.errorMessageHtml = ""; 
     var messages = ""; 
     var validationResults = regula.validate(); 
     for (var i = 0; i < validationResults.length; i++) { 
      var validationResult = validationResults[i]; 
      messages += validationResult.message + "<br />"; 
      $scope.errorMessage = messages; 
     } 
     if ($scope.errorMessage.length > 0) { 
      window.scrollTo(0, 0); 
      $scope.errorMessageHtml = $sce.trustAsHtml(angular.copy($scope.errorMessage)); 
     } 
    } 


    jQuery(document).ready(function() { 
     regula.bind(); 

     jQuery("#parentTable").blur(function() { 

      $scope.newCascade.ParentTable = jQuery("#parentTable").val(); 


      $scope.getParentField($scope.newCascade.ParentTable); 

     }); 
    }); 

    $scope.cancel = function() { 
     $scope.showForm = false; 
     $scope.successMessage = ""; 
     $scope.successMessageHtml = ""; 
     $scope.errorMessage = ""; 
     $scope.errorMessageHtml = ""; 
     $scope.loadData(); 
    } 

    $scope.ParentTableNames = function() { 

     $http.get('/api/CommonData/GetTableNameList') 
      .success(function(data, status) { 
       $rootScope.loading = false; 
       $scope.PrimaryTableNames = []; 
       $scope.PrimaryTableNames = data; 
       //console.log($scope.PrimaryTableNames); 
       $("#parentTable").kendoAutoComplete({ 
        dataSource: data, 
        filter: "startswith", 
        minLength: 3 
       }); 
       if ($scope.PrimaryTableNames && $scope.PrimaryTableNames.length) 
        $scope.showForm = false; 
      }); 
    } 
    $scope.ParentTableNames(); 

    $scope.getParentField = function (parentField) { 


     $http.get("/api/CommonData/GetParentField?parentField=" + parentField) 
     .success(function (data, status) { 

      $rootScope.loading = false; 
      $scope.PrimaryTables = []; 
      $scope.PrimaryTables = data; 
      console.log($scope.PrimaryTables); 
      if ($scope.PrimaryTables && $scope.PrimaryTables.length) 
       $scope.showForm = false; 
     }); 
    } 




    $scope.Add = function() { 
     $scope.newSemesterConfiguration = Object.create(null); 
     $scope.showForm = true; 
     $scope.successMessage = ""; 
     $scope.successMessageHtml = ""; 
     $scope.errorMessage = ""; 
     $scope.errorMessageHtml = ""; 
    } 

}); 

The Binding part in aspx: 

     <%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/App_MasterPages/BackOfficeMasterPage.master" CodeBehind="CascadeDelete.aspx.cs" Inherits="ERMAdmin_Inc.administration.CascadeDelete" %> 

<h4>Cascade Delete Configuration Setup</h4> 

<ul class="breadcrumb"> 
    <li><a href="/Dashboard/Dashboard.aspx"><i class="glyphicon glyphicon-home"></i></a></li> 
    <li><a href="/Dashboard/Dashboard.aspx?val=Administration">Administration</a></li> 
    <li>Cascade Delete Configuration Setup</li> 
</ul> 

<script src="../Scripts/ScriptAdmin/angularControllers/Administration/CascadeDeleteSetupController.js"></script> 

<div data-ng-controller="CascadeDeleteController" id="angularpage"></div> 

<div ng-show="successMessage.length" id="successmessageDiv" class="alert alert-success alert-block fade in"> 
    <button data-dismiss="alert" class="close close-sm" type="button"> 
     <i class="fa fa-times"></i> 
    </button> 
    <p>{{successMessage}}</p> 
</div> 

<div ng-show="errorMessage.length" id="errormessageDiv" class="alert alert-block alert-danger fade in"> 
    <button data-dismiss="alert" class="close close-sm" type="button"> 
     <i class="fa fa-times"></i> 
    </button> 
    <p ng-bind-html="errorMessageHtml"></p> 
</div> 

<div class="row"> 
    <div class="col-sm-8"> 
     <div class="panel panel-default"> 
      <div class="panel-heading"> 
        <h4 class="panel-title"> Add/Edit Cascade Delete</h4> 
       </div> 
      <div class="panel-body nopadding"> 
       <div class="form-horizontal form-bordered"> 
        <div class="form-group"> 
         <label class="col-lg-4 col-sm-2 control-label">Parent Table</label> 

         <div class="col-sm-8"> 

          <input id="parentTable" type="text" class="form-control" 
            data-constraints='@Required(message = "Parent Table is required.")' 
            data-ng-model="newCascade.ParentTable"> 
           <span class="mandatoryFieldMarker">*</span> 
         </div> 

        </div> 

        <div class="form-group"> 
         <label class="col-lg-4 col-sm-2 control-label">Parent Field Name</label> 
         <div class="col-sm-8"> 

          <select 
           data-ng-model="newCascade.ParentTableField" 
           data-ng-options="o.COLUMN_NAME for o in PrimaryTables" 

           class="form-control mandatoryfield" 
           data-constraints='@Required(message = "ParentTableField is required.")' 
           > 
            <option value="">Please Select</option> 
            <%--<option value="">All Departments</option>--%> 
           </select> 
           <span class="mandatoryFieldMarker">*</span> 
         </div> 

        </div> 

        <div class="btn-list" style="text-align: right; margin-right: 1.5%"> 
         <a href="" class="btn btn-success" data-ng-click="save()"><i class="fa fa-check"></i>Save</a> 
         <a href="" class="btn btn-danger" data-ng-click="cancel()"><i class="fa fa-trash-o"></i>Cancel</a> 
         <a href="" class="btn btn-success" data-ng-click="cancel()"><i class="fa fa-backward"></i>Back to List</a> 
         <a href="" class="btn btn-success" data-ng-click="saveAndAdd()"><i class="fa fa-backward"></i>Save and Add more</a> 

        </div> 
        </div> 
       </div> 
      </div> 

     </div> 
    </div> 



<div data-ng-show="PrimaryTables.length && !showForm"> 

    <div style="text-align: right"> 
     <a href="" class="btn btn-primary" data-ng-click="Add()"><i class="fa fa-plus"></i>Add New </a> 

     <br /> 
     <br /> 
    </div> 

</div> 

答えて

2

PrimaryTablesCascadeDeleteController$scopeにバインドされています。 しかし、ngControllerはすぐに閉じられるdivに置かれます。あなたが必要なもの

<div data-ng-controller="CascadeDeleteController" id="angularpage"></div>

`<div data-ng-controller="CascadeDeleteController" id="angularpage"> 
    {{PrimaryTables}} 
    <-- select with ngOptions here 
</div>` 
+0

のthnxです!できます – star101

関連する問題