Javascript 以多种html格式显示数据';s不';我不能用角
我想用HTML显示数据。第一个HTML disc-log.HTML如下所示:Javascript 以多种html格式显示数据';s不';我不能用角,javascript,html,angularjs,jhipster,Javascript,Html,Angularjs,Jhipster,我想用HTML显示数据。第一个HTML disc-log.HTML如下所示: <div> <h2>Discs</h2> <jhi-alert></jhi-alert> <div class="container-fluid"> <div class="row"> <div class="col-xs-4 no-padding-left">
<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>
Github存储库:
在控制器中,您正在discLogs变量
vm.discLogs=result中添加结果在html中,您使用的是ng repeat中的discs变量
这就是它不显示任何内容的原因。尝试使用相同的变量
注意:“您的控制器名为vm”
应该在您的ng控制器属性中,或者如果使用路由器,则应在您的路由中使用控制器:“vm”
。我想您应该将ng控制器
放在模板中。您能告诉我您如何解决这个问题吗?是否可以添加一些标记并在另一个HTML文件中显示此数据?您可以使用指令
或ng模板
进行此操作。您能给我一个示例吗?请说明如何在主HTML文件中包含单独的文件?
(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;
});
}
}
})();