2017-05-13 3 views
0

Ich möchte Daten in HTML anzeigen. Erste HTML disc-log.html sieht so aus:Anzeige Daten in vielen HTML-Codes funktioniert nicht mit Winkel

<div> 
    <h2>Discs</h2> 
    <jhi-alert></jhi-alert> 
    <div class="container-fluid"> 
     <div class="row"> 
      <div class="col-xs-4 no-padding-left"> 
       <!--<button class="btn btn-primary" ui-sref="disc.new" >--> 
        <!--<span class="glyphicon glyphicon-plus"></span>--> 
        <!--<span >--> 
         <!--Create new Disc--> 
        <!--</span>--> 
       <!--</button>--> 
      </div> 
     </div> 
    </div> 
    <br/> 
    <div class="table-responsive"> 
     <table class="jh-table table table-striped"> 
      <thead> 
       <tr> 
        <!--<th><span>ID</span></th>--> 
        <th><span>Name</span></th> 
        <th><span>Connection</span></th> 
        <th></th> 
       </tr> 
      </thead> 
      <tbody> 
       <tr ng-repeat="disc in vm.discs track by disc.id"> 
        <!--<td><a ui-sref="disc-detail({id:disc.id})">{{disc.id}}</a></td>--> 
        <td>{{disc.name}}</td> 
        <td> 
         <a ui-sref="connection-detail({id:disc.connection.id})">{{disc.connection.userHost}}</a> 
        </td> 
        <td class="text-right"> 
         <div class="btn-group flex-btn-group-container"> 
          <button type="submit" 
            ui-sref="disc-detail({id:disc.id})" 
            class="btn btn-info btn-sm"> 
           <span class="glyphicon glyphicon-eye-open"></span> 
           <span class="hidden-sm-down"></span> 
          </button> 
          <!--<button type="submit"--> 
            <!--ui-sref="disc.edit({id:disc.id})"--> 
            <!--class="btn btn-primary btn-sm">--> 
           <!--<span class="glyphicon glyphicon-pencil"></span>--> 
           <!--<span class="hidden-sm-down"></span>--> 
          <!--</button>--> 
          <button type="submit" 
            ui-sref="disc.delete({id:disc.id})" 
            class="btn btn-danger btn-sm"> 
           <span class="glyphicon glyphicon-remove-circle"></span> 
           <span class="hidden-sm-down"></span> 
          </button> 
         </div> 
        </td> 
       </tr> 
      </tbody> 
     </table> 
    </div> 
</div> 

Nach dem Öffnen dieser Website werden alle Daten angezeigt. Aber wenn ich die Tabelle in eine andere Datei kopiert habe, ist die Tabelle leer. Warum? Sollte ich etwas in Controllern oder Diensten hinzufügen?

Disc Log Controller:

(function() { 
    'use strict'; 

    angular 
     .module('deviceManagerApp') 
     .controller('DiscLogController', DiscLogController); 

    DiscLogController.$inject = ['$scope', '$state', 'DiscLog']; 

    function DiscLogController ($scope, $state, DiscLog) { 
     var vm = this; 

     vm.discLogs = []; 

     loadAll(); 

     function loadAll() { 
      DiscLog.query(function(result) { 
       vm.discLogs = result; 
       vm.searchQuery = null; 
      }); 
     } 
    } 
})(); 

Github-Repository: https://github.com/Ice94/DeviceManager

+1

Ich denke, Sie setzen 'ng-controller' in Ihrer Vorlage. –

+0

Können Sie mir sagen, dass Sie das lösen sollen? Ist es möglich, ein Tag hinzuzufügen und diese Daten in einer anderen HTML-Datei anzuzeigen? – Ice

+1

Sie können dazu 'directive' oder' ng-template' verwenden. –

Antwort

-1

In Controller Sie Ergebnis in discLogs Variable vm.discLogs = result; und in html hinzufügen Sie Scheiben Variable in ng-repeat verwenden <tr ng-repeat="disc in vm.discs track by disc.id">

Deshalb ist es nicht alles anzeigen. Versuchen Sie dieselbe Variable zu verwenden.

Hinweis:"yourControllerName as vm" im ng-Controller Attribut oder controllerAs: 'vm' in Ihren Routen sein sollte, wenn Router mit

Verwandte Themen