gpt4 book ai didi

javascript - 使用 angularjs 填充 jquery 移动表

转载 作者:行者123 更新时间:2023-11-30 17:05:56 24 4
gpt4 key购买 nike

我有一个表是使用 angularjs 开发的在图书馆的帮助下:angular-smart-table .这很好用,但我想要更多功能,所以我想使用 jquery mobile .我遇到的问题是表格是由标题组成的,但是我重复的行没有显示任何数据,我的 js 调试也没有显示任何错误。这是我的代码:

html:

<body ng-controller="MyMainController as cont">
<section ng-controller="PanelController as panel">
<span>
*span items*
</span>
<div class="panel" ng-show="panel.isSelected(1)">
<table data-role="table" id="table-custom-2" data-mode="columntoggle" class="ui-body-d ui-shadow table-stripe ui-responsive" data-column-btn-theme="b" data-column-btn-text="Columns" data-column-popup-theme="a">
<thead>
<tr class="ui-bar-d">
<th></th>
<th data-priority="1" st-sort="account">Account #</th>
<th st-sort="name">Campaign Name</th>
<th data-priority="4">Comments</th>
<th data-priority="2" st-sort="priority">Priority</th>
<th data-priority="2" st-sort="zipCode">Zip Code</th>
<th data-priority="2" st-sort="address">Address</th>
<th data-priority="2" st-sort="status">Status</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in cont.tableRows">
<td>{{row.checked}}</td>
<td>{{row.account}}</td>
<td>{{row.name}}</td>
<td>{{row.comments}}</td>
<td>{{row.priority}}</td>
<td>{{row.zipCode}}</td>
<td>{{row.address}}</td>
<td>{{row.status}}</td>
</tr>
</tbody>
</table>
</div>
<div class="panel" ng-show="panel.isSelected(2)" id="map-canvas">
Map
</div>
</section>
*my javascript tags*
</body>

js:

(function(){
var myVar = angular.module('cont', []);

myVar.controller('MyMainController', ['$scope', '$filter', function (scope, filter){
scope.tableRows = [
{
checked: false,
account: 1,
name: "Name1",
comments: "Comments`",
priority: "High",
zipCode: 11111,
address: "Address",
status: "Active"
},
{
checked: true,
account: 2,
name: "Name2",
comments: "Comments2",
priority: "Medium",
zipCode: 22222,
address: "Address2",
status: "Active"
},
{
checked: false,
account: 3,
name: "Name3",
comments: "Comments3",
priority: "Low",
zipCode: 33333,
address: "Address3",
status: "Active"
},
{
checked: false,
account: 4,
name: "Name4",
comments: "",
priority: "Low",
zipCode: 44444,
address: "Address4",
status: "Active"
}];
}]);

leadPlanning.controller('PanelController', function(){
this.tab = 1;
this.selectTab = function(setTab) {
this.tab = setTab;
}
this.isSelected = function(checkTab) {
return this.tab === checkTab;
}
});

})();

如我所说,带有列标题的行显示正常,但实际数据显示不正确,这让我相信我的 ng-repeat 存在问题。我之前的表格实际上显示了数据,除了 <table> 中的代码基本相同。我的标签:st-table="tableRows" (对于智能表库)然后我的重复是:ng-repeat="row in tableRows" .这是我第一次同时使用 angularjsjquery mobile因此,我们将不胜感激!

最佳答案

它不会重复,因为您没有将 tableRows 附加到 Controller 实例 @ scope.tableRows,而是它在范围内并且您从通过执行 cont.tableRow 来为 Controller 实例别名。

尝试:-

 this.tableRows = [...

Plnkr

关于javascript - 使用 angularjs 填充 jquery 移动表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28028787/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com