我有一个对象数组,我想要显示在一个滚动窗口使用纳克重复类似的结构角。到目前为止,我正在使用角UI实用程序滚动条。
我读过读给我听,也读过这个答案给出的关于堆栈溢出的前一个问题的这个例子。因此,在我的代码中,这是我目前所拥有的,它在运行时不会出现错误,也不会显示任何内容。
我的模块定义中的:
var app = angular.module('PromoUI', ['ngRoute', 'angularUtils.directives.dirPagination', 'ui.bootstrap','ui.scroll','ui.scroll.jqlite'])我的控制器中的:
$scope.datasource = {
get: function (index, count, success) {
success($scope.discounts)
}
}在我看来:
{{discounts[0].PromoCode}}
<div ui-scroll-viewport style="height:300px">
<div ui-scroll="discount in datasource">
<p>{{discount.PromoCode}}</p>
<p>{{discount.DiscountDescription}}</p>
</div>
</div>(请注意,{{discounts.PromoCode}}在浏览器中正确显示)
和我的参考资料是正确的:
<!--ANGULAR UI-->
<script src="../Scripts/angular-ui/ui-utils.js"></script>我有种感觉,我没有正确地设置数据源。有谁用过这个指令能帮我一把吗?
发布于 2015-03-01 05:54:52
我认为你所拥有的可能也会起作用,但我把它设置如下:
app.factory('datasource', ['$timeout', function($timeout) {
var a = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'];
var get = function (index, count, success) {
return success(a);
};
return {
get: get
};
}
]);
我在http://plnkr.co/edit/W8Mzee也有这样的想法
https://stackoverflow.com/questions/27710964
复制相似问题