angularjs-ng-repeat

AngularJS ng-repeat with custom element inside a table is rendering strangely

倖福魔咒の 提交于 2019-11-28 04:56:10
I'm trying to re-use a portion of my HTML view in multiple places. The portion I want to re-use is table cells in an HTML table. The problem is that my custom directive inside a ng-repeat is doing funny things. I have reproduced the problem on jsFiddle . There are two HTML tables in the jsFiddle. The first is ng-repeat with the table cells written in the view and the second is the table cells coming from a directive, my-element. Chrome dev tools report that the rendered HTML looks like this. Note that the custom element appears only once and is outside the table. Rendered HTML <div ng

Angular ng-change delay

十年热恋 提交于 2019-11-28 04:36:13
I have an input which filters a ng-repeat list on change. The repeat contains a lot of data and takes a few seconds to filter through everything. I would like their to be 0.5 second delay before I start the filtering process. What is the correct way in angular to create this delay? Input <input ng-model="xyz" ng-change="FilterByName()" /> Repeat <div ng-repeat"foo in bar"> <p>{{foo.bar}}</p> </div> Filter Function $scope.FilterByName = function () { //Filtering Stuff Here }); Thanks rckd AngularJS 1.3+ Since AngularJS 1.3 you can utilize the debounce property ngModelOptions provides to achieve

ng-repeat orderBy object

你离开我真会死。 提交于 2019-11-28 03:49:48
问题 UPDATE: on my html page I'm using as the following: <section ng-repeat="template in templates"> <ng-include src="template"></ng-include> </section> but the problem is that I need specific file in certain order so is there a way I can control the way order is rendering? I'm trying to orderby an object how do I do that and I have searched online before posting it here. function MyCtrl($scope) { $scope.templates = { template_address: "../template/address.html", template_book: "../template/book

In Angular, how to pass JSON object/array into directive?

百般思念 提交于 2019-11-28 02:57:18
Currently, my app has a controller that takes in a JSON file then iterates through them using "ng-repeat". This is all working great, but I also have a directive that needs to iterate through the same JSON file. This is posing a problem as I cannot request the same JSON file twice on one page (nor would I want to because it would be inefficient). Both the directive and controller request and iterate through the JSON data just fine if I change the filename of one of the JSON files. What I'm wondering is: what's the best way to go about passing the array formed from my controller's JSON request

How to remove elements/nodes from angular.js array

柔情痞子 提交于 2019-11-28 02:54:55
I am trying to remove elements from the array $scope.items so that items are removed in the view ng-repeat="item in items" Just for demonstrative purposes here is some code: for(i=0;i<$scope.items.length;i++){ if($scope.items[i].name == 'ted'){ $scope.items.shift(); } } I want to remove the 1st element from the view if there is the name ted right? It works fine, but the view reloads all the elements. Because all the array keys have shifted. This is creating unnecessary lag in the mobile app I am creating.. Anyone have an solutions to this problem? There is no rocket science in deleting items

AngularJS sorting rows by table header

人盡茶涼 提交于 2019-11-28 02:52:37
I have four table headers: $scope.headers = ["Header1", "Header2", "Header3", "Header4"]; And I want to be able to sort my table by clicking on the header. So if my table looks like this H1 | H2 | H3 | H4 A H D etc.... B G C C F B D E A and I click on H2 my table now looks like this: H1 | H2 | H3 | H4 D E A etc.... C F B B G C A H D That is, the content of each column never changes, but by clicking on the header I want to order the columns by, the rows will reorder themselves. The content of my table is created by a database call done with Mojolicious and is returned to the browser with $scope

Automatic Serial Nos in ng-Repeat (Angular)

风格不统一 提交于 2019-11-28 02:17:17
I am using ng-Repeat to fill the table with data in Controller (or from Services). However, I need to fullfill Serial Nos in first column automatically. Currently I am getting only static data as 1 in all columns. HTML: <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> </head> <body ng-app="myApp" ng-controller="myCtrl"> <table> <tr><th>S.No.</th><th>Name</th></tr> <tr ng-repeat="x in People"><td>1</td><td>{{x.name}}</td></tr> </table> <script> var app = angular.module('myApp',[]); app.controller('myCtrl',function($scope){ $scope.People =

ng-init in ng-repeat shows only the last item info

落花浮王杯 提交于 2019-11-28 01:43:25
I want to loop through items like this: <section class="col-sm-4" data-ng-controller="PredictionsController" data-ng-init="findMyPredictions()"> <div class="games"> <div class="game-row" ng-repeat="prediction in predictions" ng-init="getGame(prediction.game_id)"> <a class="button primary alt block" href="#!/predictions/{{prediction._id}}"> <span class="home flag {{gameInfo.team1_key}}"></span> <span class="middle"> <span class="date">{{gameInfo.play_at | date: 'd.MM HH:mm'}}</span> <span class="versus">{{gameInfo.team1_title}} - {{gameInfo.team2_title}}</span> </span> <span class="away flag {

Angular orderBy Date

有些话、适合烂在心里 提交于 2019-11-28 01:39:35
I have an array which I want to order by date in Angular.js: <tr ng-repeat="er in vm.readerFeeds | orderBy:'-publishedDate'"> <td>{{er.publishedDate}}</td> </tr> The list ist not ordered right. I think the date format is the cause? Date format is: Sat, 09 Nov 2013 04:26:55 -0800 To make to orderBy to work you need wrap string date with object of new Date(/**/) in controller. For example: $scope.vm.readerFeeds = [ { //..... publishedDate: new Date(/*your string date*/); }, { //..... publishedDate: new Date(/*your string date*/); } ]; <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN

nested table using ng-repeat

拥有回忆 提交于 2019-11-27 23:49:45
问题 What I'm trying to do is repeat three levels. Demo: http://plnkr.co/edit/qXLcPHXDlOKZYI5jnCIp?p=preview <table> <thead> <tr> <td>Block</td> <td>Column</td> <td>Unit</td> <td>Action</td> </tr> </thead> <tbody ng-repeat="block in building.ownBlock"> <tr ng-repeat="column in block.ownColumn"> <td>{{block.name}}</td> <td>{{column.number}}</td> <td>{{unit.name}} - ? empty</td> <td><button ng-click="edit(unit)">Edit</button></td> </tr> </tbody> </table> but I have failed to do so. Collection $scope