2017-07-12 2 views
-1

Ich versuche, eine dynamische Tabelle mit Angularjs zu entwerfen, und ich fand nützlich, die ng-Repeat-Funktion.ng-Wiederholung in Tabellenzeilen zeigt keine Zeilen

Nach einigen Versuchen bin ich nicht weiß, wie es nicht funktioniert, weil mein Attribut funktioniert gut, aber meine zeigt nichts

hier ist meine Js

.controller('DispatcherFilterController', 
     [ '$scope', 
function($scope,{ 
      $scope.dispatcherSearch=[{ 
        id: 1, 
        name: 'out1', 
        description :'desc1', 
        vat_number :'378297', 
        dispatch_type :'daily', 
        output : 'out1' 
       }, { 
        id: 2, 
         name: 'out2', 
         description :'desc2', 
         vat_number :'3782f97', 
         dispatch_type :'daily', 
         output : 'out2' 
       }, 
       { 
        id: 3, 
         name: 'out3', 
         description :'desc3', 
         vat_number :'fssfes', 
         dispatch_type :'daily', 
         output : 'out3' 
       }];}]) 

und hier mein HTML ist :

<div class="table-responsive"> 
    <table class="table" ng-controller="DispatcherFilterController"> 
     <thead> 
      <tr> 
       <th class="col-order"><a class="sort asc" href="#" title="">{{'NAME' 
            | translate}}</a> 
       </th> 
       <th class="col-order"><a class="sort asc" href="#" title="">{{'DESCRIPTION' 
            | translate}}</a> 
       </th> 
       <th class="col-order"><a class="sort asc" href="#" title="">{{'VAT_NUMBER' 
            | translate}}</a> 
       </th> 
       <th class="col-order"><a class="sort asc" href="#" title="">{{'DISPATCH_TYPE' 
            | translate}}</a> 
       </th> 
       <th class="col-order"><a class="sort asc" href="#" title="">{{'OUTPUT' 
            | translate}}</a> 
       </th> 
       <th class="colf-cmd"></th> 
      </tr> 
     </thead> 
     <tbody> 
      <tr ng-repeat="row in dispatcherSearch"> 
       <td>{{row.name}}</td> 
       <td>{{row.description}}</td> 
       <td>{{row.vat_number}}</td> 
       <td>{{row.dispatch_type}}</td> 
       <td>{{row.output}}</td> 
       <td class="colf-cmd"> 
        <div class="form-inline pull-right"> 
         <div class="form-group"> 
          <div class="form-btn-container"> 
           <button type="button" class="btn btn-primary pull-right" ng-click="spot()">{{'SPOT' | translate}}</button> 
          </div> 
         </div> 
         <div class="form-group"> 
          <div class="form-btn-container"> 
           <button type="button" class="btn btn-primary pull-right" ng-click="periodic()">{{'PERIODIC' | translate}}</button> 
          </div> 
         </div> 
        </div> 

       </td> 

      </tr> 
     </tbody> 
    </table> 

wo ging ich schief?

+0

jeder Konsole eine Fehlermeldung? –

Antwort

2

Es war Syntaxfehler in Ihrem Controller-Code zu vervollständigen. Auch haben Sie keinen Code für was translate Filter gegeben, also habe ich das auch entfernt und wir haben eine funktionierende Solution hier.

-Controller

.controller('DispatcherFilterController', ['$scope', 
      function($scope) { 
       $scope.dispatcherSearch = [{ 
        id: 1, 
        name: 'out1', 
        description: 'desc1', 
        vat_number: '378297', 
        dispatch_type: 'daily', 
        output: 'out1' 
       }, { 
        id: 2, 
        name: 'out2', 
        description: 'desc2', 
        vat_number: '3782f97', 
        dispatch_type: 'daily', 
        output: 'out2' 
       }, { 
        id: 3, 
        name: 'out3', 
        description: 'desc3', 
        vat_number: 'fssfes', 
        dispatch_type: 'daily', 
        output: 'out3' 
       }]; 
      }]); 
0

Sie haben vergessen, Reglerfunktion Hier wird korrigiert Controller-Code Jsfiddle

Js Code

var app = angular.module('myApp', []); 

app.controller('DispatcherFilterController', ['$scope', 
    function($scope) { 
    $scope.dispatcherSearch = [{ 
     id: 1, 
     name: 'out1', 
     description: 'desc1', 
     vat_number: '378297', 
     dispatch_type: 'daily', 
     output: 'out1' 
    }, { 
     id: 2, 
     name: 'out2', 
     description: 'desc2', 
     vat_number: '3782f97', 
     dispatch_type: 'daily', 
     output: 'out2' 
    }, { 
     id: 3, 
     name: 'out3', 
     description: 'desc3', 
     vat_number: 'fssfes', 
     dispatch_type: 'daily', 
     output: 'out3' 
    }]; 
    } 
]); 

Diese Arbeit wird

Verwandte Themen