Tag: angularjs ng repeat

AngularJS:在每个项目的点击上添加相同的结构

我的index.html页面如下: {{item.name}} 对于这个ng-view我有record-list.html来显示所有记录,如下所示: …… 现在我想添加相同的结构(就像每条记录一样)附加在侧面板的每个项目的点击上。 这是什么逻辑? 我最近的UI看起来像这样我希望在每次点击时添加相同的结构,这应该附加现有结构。 请帮忙。谢谢。

加载Ng-Repeat元素后运行的jQuery Swiper脚本

我正在使用AngularJS,jQuery,HTML,CSS和Bootstrap创建一个Web应用程序,我想从我的JSON中选择一些位于Apache2服务器中的图像链接并使用它们来在我的主页面中呈现这些图像。 我也想像旋转木马一样刷它们。 为了做到这一点,我正在尝试使用iDangero.us Swiper 。 当我用3个分开的div选择我的图像时,我没有问题。 我得到了我的图像然后我可以按照我想要的方式刷它们。 我这样做如下所示: main.html中: 我使用Swiper从一个图像滑动到另一个图像,它似乎应该工作。 这是一个jQuery插件,你可以在这个链接上看到一些演示。 Swipers.js: angular.module(‘swipers’, []) .controller(”,[ $(document).ready(function (){ var swiper = new Swiper(‘.swiper-container’,{ direction: ‘horizontal’, pagination: ‘.swiper-pagination’, paginationClickable: true }) })]); JSON: “background1″:”background-image: url(images/img1.jpg)”, “background2″:”background-image: url(images/img2.jpg)”, “background3″:”background-image: url(images/img3.jpg)” mainController.js: myApp.controller(‘MainController’, [“$scope”,”$http”, function($scope,$http){ $scope.initGetRequestMain = function(){ $http.get(‘http://localhost/main.json’).success(function(data){ $scope.data=data; }) } }]); 问题是,当我尝试使用ng-repeat而不是3个单独的div时,我再也看不到它们了,我的Swiper脚本在完全加载之前就会触发。 我的控制台或JSON中没有错误(使用JSONLintvalidation)。 下面,我在两种情况下都添加了2个输出屏幕截图。 使用3个独立的div: 不使用ng-repeat: 这是我尝试使ng-repeat工作保持与以前相同的控制器和相同的Swiper脚本的代码: […]

在javascript中实现角度ng-repeat特征

我目前正在研究一种代码来实现像角度的ng-repeat。 基本上是html中的for循环。 代码使用类“loop”获取每个元素,并使用通过“info”属性给出的信息对其进行处理。 这是代码:HTML -i- 使用Javascript $(“.loop”).each(function(i){ var loop_info=$(this).attr(“data-info”); var fin=loop_info.match(/(.*) in (\d+) to (\d+)/); var variable=fin[1], initial=fin[2], final=fin[3]; var htm=$(this).html(),printed=””; for(j=initial;j<=final;j++){ var temp=htm; var r=new RegExp("-("+variable+")-","g") temp=temp.replace(r,j); printed+=temp; } $(this).html(printed); }); 现在我还包括用数字替换 – 变量的function。 一切都很完美,但是当循环嵌套时,即 -j- 它不适用于嵌套循环,即-j-不会被数字替换。 我不知道为什么会这样,任何帮助都表示赞赏。

jQuery没有使用ng-repeat结果

我正在使用ng-repeat来构建一个使用jQuery和TB的手风琴。 出于某种原因,这在硬编码时工作正常,但在ng-repeat指令内部无法触发。 我当时认为问题是来自jQuery而不是事后加载的绑定元素。 所以,我认为不是在页面加载时加载脚本,而是在返回数据时在.success上加载函数会更好。 不幸的是,我无法弄清楚如何使这项工作。 测试页面 : http : //staging.converge.io/test-json 控制器 : function FetchCtrl($scope, $http, $templateCache) { $scope.method = ‘GET’; $scope.url = ‘https://www.googleapis.com/pagespeedonline/v1/runPagespeed?url=http://www.web.com&key=AIzaSyA5_ykqZChHFiUEc6ztklj9z8i6V6g3rdc’; $scope.key = ‘AIzaSyA5_ykqZChHFiUEc6ztklj9z8i6V6g3rdc’; $scope.strategy = ‘mobile’; $scope.fetch = function() { $scope.code = null; $scope.response = null; $http({method: $scope.method, url: $scope.url + ‘&strategy=’ + $scope.strategy, cache: $templateCache}). success(function(data, status) { $scope.status = status; […]

在Angular JS中跳过重复JSON排序

当我使用ng-repeat(可能是一种无痛的方式)时,有没有人知道如何完全跳过 JSON排序? 例如,我的源JSON看起来像这样 – { “title”: “Title”, “description”: “Description”, “moreInfo”: “Moreinformation” } 一旦我在ng-repeat中使用它,它就按字母顺序排序。 像这样的东西 – { “description”: “Description”, “moreInfo”: “Moreinformation”, “title”: “Title” } 我的ng-repeat看起来像这样 – {{key}} {{data}} 我见过人们有一个单独的键数组,并使用它们来识别JSON对象,最终避免按字母顺序排序。 有一种优雅的方式来做到这一点?