2016-10-25 8 views
0

私はSQL接続用にanglejsを使用しているWebアプリケーションを作成しています。angularjsのデータがテーブルに表示されない

adminのデータが2人のユーザー(adminRegional Partner Manager)に表示されていますが、地域のパートナーマネージャーのデータが表示されません。

$scope.getsonvindata = function() { 
      $scope.loadimage = true; 
      $scope.names = ''; 
      $scope.resetfilters(); 
      //$scope.area = location; 
      // get sonvin data list and stored in sonvinrpm $scope variable 
      $http.get('/angularwebservice/frmcosonvinrpm4.asmx/frmsonvinrpm', { 
       params: { 
        log: log, 
        from: $scope.from, 
        to: $scope.to, 
        pm: pm 
       } 
      }) 
      .then(function (response) { 
       $scope.sonvinrpm = response.data.procompanysonVin; 
       console.log($scope.sonvinrpm); 
       //pagination 
       $scope.totalItems = $scope.sonvinrpm.length; 
       $scope.numPerPage = 50000; 
       $scope.paginate = function (value) { 
        var begin, end, index; 
        begin = ($scope.currentPage - 1) * $scope.numPerPage; 
        end = begin + $scope.numPerPage; 
        index = $scope.sonvinrpm.indexOf(value); 
        return (begin <= index && index < end); 
       }; 

       $scope.loadimage = false; 
       if ($scope.sonvinrpm == '') { 
        $scope.errormessage = 'Data Not Found... Please Select Correct Date Range'; 
       } 
       else { 
        $scope.errormessage = ''; 
       } 
      }); 

私のテーブル::

<table id="table" class="table table-bordered font" style="width: 110%;"> 
        <thead> 
         <tr class="bg-primary"> 
          <th>Edit</th> 
          <th><a href="#" ng-click="order('name')" class="erp-tb-a">SrNo</a></th> 
          <th><a href="#" ng-click="order('date')" class="erp-tb-a">Date</a></th> 
          <th><a href="#" ng-click="order('venuename')" class="erp-tb-a">Hotel/School</a></th> 
          <th><a href="#" ng-click="order('venue')" class="erp-tb-a">Venue</a></th>         
          <th><a href="#" ng-click="order('zone')" class="erp-tb-a">Zone</a></th> 
          <th><a href="#" ng-click="order('location')" class="erp-tb-a">Location</a></th> 
          <th><a href="#" ng-click="order('starttime')" class="erp-tb-a">Start Time</a></th>    
          <th><a href="#" ng-click="order('brand')" class="erp-tb-a">Brand Name</a></th> 
          <th><a href="#" ng-click="order('program')" class="erp-tb-a">Program</a></th> 

          <%--<th>Count</th>--%>       
         </tr> 
        </thead> 
        <tbody> 
        <tr class="bg-primary"> 
         <td><i class="glyphicon glyphicon-filter"></i></td> 
         <td></td> 
         <%--<th>SonvinId</th>--%> 
         <td> 
          <div class="left-margin form-control-wrapper form-group has-feedback has-feedback"> 
           <input type="text" class="date floating-label erp-input" ng-model="search.date" placeholder="Date"> 
          </div> 
         </td> 
         <td> 
          <input type="text" ng-model="search.venuename" placeholder="Hotel/School" class="erp-input" /></td> 
         <td> 
          <input type="text" ng-model="search.venue" placeholder="Venue" class="erp-input" /> 
         </td> 
         <%--<th>Day</th>--%> 
         <%--<th>Company</th>--%> 
         <td> 
          <input type="text" ng-model="search.zone" placeholder="Zone" class="erp-input" /></td> 
         <td> 
          <input type="text" ng-model="search.location" placeholder="Location" class="erp-input"></td> 
         <td> 
          <%--<div class="form-control-wrapper"> id="time"--%> 
           <input type="text" ng-model="search.starttime" class="floating-label erp-input" placeholder="Start Time"> 
          <%--</div>--%> 
         </td> 
         <%-- <th>End</th>--%> 
         <%--<th>Hrs</th>--%> 
         <td> 
          <input type="text" ng-model="search.brand" placeholder="Brand Name" class="erp-input" /></td> 
         <td> 
          <input type="text" ng-model="search.program" placeholder="Program" class="erp-input" /></td>       
        </tr> 
        <%--| filter :{date: mddate,brand: mdbrand, zone: mdzone, location: mdlocation, starttime: mdstart,program: mdprogram,venuename: mdvenuename,venue: mdvenue }--%> 
        <tr ng-repeat="x in sonvinrpm | orderBy:predicate:reverse | filter:paginate| filter:search"> 
         <td><button type="button" ng-click="getassigntrainerdata(x)" class="btn btn-sm btn-primary" data-controls-modal="modal-from-dom" data-backdrop="static" data-keyboard="true" data-toggle="modal" data-target="#assigntrainermodel"><i class="glyphicon glyphicon-pencil"></i></button></td> 
         <td>{{x.srno}}</td> 
         <%--<td>{{x.sonvinid}}</td>--%> 
         <td>{{x.date}}</td> 

         <td class="bg-success"><a ng-bind="x.venuename" ng-click="DetailsFunction(x)" class="erp-table-a" data-controls-modal="modal-from-dom" data-backdrop="static" data-keyboard="true" data-toggle="modal" data-target="#Detailsmodel"></a></td> 
         <td>{{x.venue}}</td> 
         <%-- <td>{{x.day}}</td>--%> 
         <%--<td>{{x.company}}</td>--%>       
         <td>{{x.zone}}</td> 
         <td>{{x.location}}</td> 
         <td>{{x.starttime}}</td> 
         <%--<td>{{x.endtime}}</td>--%> 
         <%--<td>{{x.hrs}}</td>--%> 
         <td>{{x.brand}}</td> 
         <td>{{x.program}}</td> 
         <%--<td>count</td>--%> 
        </tr> 
        <tr> 
         <td colspan="12"><pagination total-items="totalItems" ng-model="currentPage" max-size="5" boundary-links="true" items-per-page="numPerPage" class="pagination-sm"></pagination></td> 
        </tr> 
         </tbody>          
       </table> 

、今、私は私のリージョナルパートナーマネージャーのためのWebサービスから取得していたデータ:

{"procompanysonVin":[{"srno":1,"sonvinid":null,"id":3401,"date":"22-10-2016","day":"Sat  ","company":24,"brand":"QED - TM","zone":"East","location":"Kolkata ","starttime":"10:00","endtime":"12:00","hrs":"02:00:00 ","program":"HBKBH","venuename":" NARAYANA SCHOOL","venue":" SITLA ASANSOL"},{"srno":2,"sonvinid":null,"id":3400,"date":"23-10-2016","day":"Sun  ","company":24,"brand":"QED - TM","zone":"East","location":"Kolkata ","starttime":"10:00","endtime":"12:00","hrs":"02:00:00 ","program":"HBKBH","venuename":"NARAYANA SCHOOL","venue":" BENGAL AMBUJA HOUSING COMPLEX AMBUJA DURGAPUR WEST BENGAL"}]} 

ここ

は私のjsファイルでありますデータが私のwebserviceに来て、何が間違っていますか?

注:管理者のデータはなく、地域のパートナーマネージャー

+0

は、あなたがテーブルを表示する前にデータをロードしようとした働きリンクであるリバース:述語:

$scope.predicate = 'venue'; $scope.reverse = true; 

はその後、NGリピート ORDERBYに追加スコープに追加しますか?テーブルの先頭に「ng-if = "sonvinrpm && search"」と表示されます。

Wandrille

+0

$ scopeに問題があると思います。httpのsonvinrpmは応答を取得し、どのデータがconsole.log($ scope.sonvinrpm)になるかを出力できます。 ithinkは "$ scope.sonvinrpm = response.procompanysonVin;"にする必要がありますあなたの応答に従ってこの からデータを削除してください –

+0

問題は 'filter:search'で一度削除し、それが来ているかどうかを確認してから、後で追加することができます。'

' – Sravan

答えて

0

まず最初は、私はどこにいる見つけることができませんでしたです$ scope.getsonvindata関数を呼び出します。関数を定義するだけで、コード内のどこでも呼び出すことはできません。この

$scope.getsonvindata(); 

のように第二に、あなたが誤ってフィルタを適用しています。 フィルタで注文を設定する適切な方法は次のとおりです。

ここ

https://jsfiddle.net/U3pVM/27907/

0

.then(function()あなたは

テーブルにデータを設定しながら
$scope.sonvinrpm = response.data.procompanysonVin; 

しかし、あなたが設定したデータモデルとして設定されていて、私のテーブルの上に印刷されますsearch.zone,search.location,search.dateなど

まず、データアクセスのためにキーを修正する必要があります。

第2に、httpリクエストから取得しているデータは、配列を含むオブジェクトです。

したがって、テーブルに表示するためにデータをトラバースするには、ng-repeat(または他の反復ロジック)を使用する必要があります。

第三に、sonvinrpmは、オブジェクトがある、だから、

if ($scope.sonvinrpm == '') { 
    $scope.errormessage = 'Data Not Found... Please Select Correct Date Range'; 
} 

を置き換えてくださいnullまたはundefinedチェックを行う必要があり

if (!$scope.sonvinrpm) { 
    $scope.errormessage = 'Data Not Found... Please Select Correct Date Range'; 
} 
関連する問題