Questions tagged «angularjs-ng-repeat»

ngRepeat指令对集合中的每个项目实例化一次模板。每个模板实例都有其自己的作用域,其中给定的循环变量设置为当前集合项,`$ index`设置为项索引或键。

3
跨多个元素的Angular.js ng-repeat
此问题已在此处部分解决:跨多个tr的Angular.js ng-repeat 但是,这实际上只是一种变通方法,它实际上并未解决核心问题,即:如何在没有包装的情况下跨多个元素使用ng-repeat? 例如,jquery.accordion要求您重复一个h3和div元素,用ng-repeat怎么做?

2
通过布尔属性用“ track by”过滤Angular 1.2 ng-repeat
我正在尝试根据布尔属性的值过滤一些列表项,但是无论我做什么,总会显示整个列表。我尝试过的一些东西已经坏掉了,什么也没显示,但这既不存在也不存在。我无法按需进行过滤: $scope.attendees = [ {"firstname":"Steve", "lastname":"Jobs", "arrived":true, "id":1} ,{"firstname":"Michelle", "lastname":"Jobs", "arrived":false, "id":2} ,{"firstname":"Adam", "lastname":"Smith", "arrived":true, "id":3} ,{"firstname":"Megan", "lastname":"Smith", "arrived":false, "id":4} ,{"firstname":"Dylan", "lastname":"Smith", "arrived":false, "id":5} ,{"firstname":"Ethan", "lastname":"Smith", "arrived":false, "id":6} ]; 使用以下ng-repeat过滤: <ul> <li ng-repeat="person in attendees track by person.id | filter:arrived:'false'"> {{person.lastname}}, {{person.firstname}} </li> </ul> 我觉得我已经尝试了所有可以找到引用的排列,其中大部分来自各种StackOverflow搜索结果: filter:'arrived' filter:arrived filter:'person.arrived' filter:person.arrived filter:{arrived:true} …

8
angularjs ng-style:背景图像不起作用
我正在尝试通过使用angular将背景图像应用于div ng-style(我之前尝试过使用具有相同行为的自定义指令),但是它似乎没有用。 <nav class="navigation-grid-container" data-ng-class="{ bigger: isNavActive == true }" data-ng-controller="NavigationCtrl" data-ng-mouseenter="isNavActive = true; $parent.isNavActive = true" data-ng-mouseleave="isNavActive = false; $parent.isNavActive = false" data-ng-show="$parent.navInvisible == false" data-ng-animate="'fade'" ng-cloak> <ul class="navigation-container unstyled clearfix"> <li class="navigation-item-container" data-ng-repeat="(key, item) in navigation" data-ng-class="{ small: $parent.isNavActive, big: isActive == true }" data-ng-mouseenter="isActive = true; isInactive= …

12
如何从angular.js数组中删除元素/节点
我试图从数组中删除元素,$scope.items以便在视图中删除项目ng-repeat="item in items" 仅出于说明目的,下面是一些代码: for(i=0;i<$scope.items.length;i++){ if($scope.items[i].name == 'ted'){ $scope.items.shift(); } } 如果名称正确,我想从视图中删除第一个元素吗?它工作正常,但是视图会重新加载所有元素。因为所有阵列键都已移动。这在我正在创建的移动应用程序中造成了不必要的延迟。 有人对此问题有解决方案吗?

8
Angular-无法进行ng-repeat订单
我已经用orderBy尝试了许多ng-repeat的例子,但是我无法使json与它一起工作。 <div ng-app> <script type="text/javascript" src="http://code.angularjs.org/1.0.1/angular-1.0.1.js"></script> <div ng:controller="Main"> <div ng-repeat="release in releases| orderBy:'environment_id'"> {{release.environment_id}} </div> </div> </div> 还有JSON function Main($scope) { $scope.releases = { "tvl-c-wbap001 + tvl-webapp": { "timestamp": " 05:05:53 PM ", "environment_id": "CERT5", "release_header": "Projects/Dev", "date": "19 Oct", "release": "12.11.91-1" }, "tvl-c-wbap401 + tvl-webapp": { "timestamp": " 10:07:25 …

3
使用ng-if作为ng-repeat内部的开关?
我正在使用Angular应用程序。我尝试使用ng-if并在ng-repeat中切换,但没有成功。我有类似的数据: **[{"_id":"52fb84fac6b93c152d8b4569", "post_id":"52fb84fac6b93c152d8b4567", "user_id":"52df9ab5c6b93c8e2a8b4567", "type":"hoot",}, {"_id":"52fb798cc6b93c74298b4568", "post_id":"52fb798cc6b93c74298b4567", "user_id":"52df9ab5c6b93c8e2a8b4567", "type":"story",}, {"_id":"52fb7977c6b93c5c2c8b456b", "post_id":"52fb7977c6b93c5c2c8b456a", "user_id":"52df9ab5c6b93c8e2a8b4567", "type":"article",},** $ scope.comments =上面提到的数据 和我的HTML一样: <div ng-repeat = "data in comments"> <div ng-if="hoot == data.type"> //differnt template with hoot data </div> <div ng-if="story == data.type"> //differnt template with story data </div> <div ng-if="article == data.type"> //differnt template with …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.