angularjs-ng-repeat

ng-repeat in nested array in AngularJS

人走茶凉 提交于 2019-12-18 17:05:07
问题 I am having a problem. I have an array. myArray = [{ "John": [{"salary":"15K","year":"2013"},{"salary":"20K","year":"2014"}] },{ "Ben": [{"salary":"17K","year":"2013"},{"salary":"20K","year":"2014"},{"salary":"25K","year":"2014"}] }]; I want it to display in a table.The array can have much more data. Please someone, tell me If I am arranging the array wrong or something. I am stuck in this for sometime now. 回答1: a table for each user : http://plnkr.co/edit/LSkW8mWwloDF65iahbAH?p=preview <div

AngularJS ngRepeat update model

China☆狼群 提交于 2019-12-18 14:53:02
问题 I use ng-repeat to render a html table . My controller looks like so: app.controller("fooCtrl", function($scope, WebSocket) { $scope.foo = [ ... ]; WebSocket.start(function(data) { // this is a callback on websocket.onmessage // here is a for loop iterating through $scope.foo objects and updating them }); }); As you can see, I am updating the $scope.foo array periodically. However, my view is constructed like so: <tr ng-repeat="item in foo"> ... </tr> The problem is, when I update foo , it

AngularJS ngRepeat update model

爷,独闯天下 提交于 2019-12-18 14:52:17
问题 I use ng-repeat to render a html table . My controller looks like so: app.controller("fooCtrl", function($scope, WebSocket) { $scope.foo = [ ... ]; WebSocket.start(function(data) { // this is a callback on websocket.onmessage // here is a for loop iterating through $scope.foo objects and updating them }); }); As you can see, I am updating the $scope.foo array periodically. However, my view is constructed like so: <tr ng-repeat="item in foo"> ... </tr> The problem is, when I update foo , it

ng-repeat's element not updated on array modification

☆樱花仙子☆ 提交于 2019-12-18 13:19:47
问题 When I trying to update my array on ng-click in order to update my ng-repeat's directive items: <li ng-repeat="itemL1 in mainMenuL1Arr" ng-click="selectL2menu(itemL1.name)"> <i ng-class="getClass(itemL1.icon)"></i> </li> selectL2menu() defined on controller as: $scope.selectL2menu = function selectL2menu(itemL1name){ $scope.$apply(function () { $scope.mainMenuL2CurArr = $scope.mainMenuL2Obj[itemL1name]; }); } Right after click on 1st level menu item it should reveal 2nd level menu block with

calculate the sum of values in ng repeat Angularjs

感情迁移 提交于 2019-12-18 12:39:00
问题 I am new to Angularjs. I am displaying list of items using ng-repeat. how to calculate the sum of it? is there any simple method to calculate it in html using expression? name numberofyears amount interest xxx 2 4000 4% yyy 3 3000 10% zzz 5 6000 6% Total 10 13000 16% First three rows are from ng repeat.I just want to calculate the total as shown above. Thanks in advance This is pretty similar to Calculating sum of repeated elements in AngularJS ng-repeat this question. But not exactly. I am

AngularJs sort object in ngRepeat

眉间皱痕 提交于 2019-12-18 12:18:40
问题 I'm using AngularJs and found a problem in ordering properties of a hash object in a template. My object is like: function TestCtrl($scope){ $scope.week = {'MONDAY': ['manuel'], 'TUESDAY': [], 'WEDNESDAY': ['valerio'], 'THURSDAY': ['manuel', 'valerio'], 'FRIDAY': []} } Now, when I try to print these values in my template: <div ng-repeat="(day, names) in week"> <span>{{day}}</span> <ul> <li ng-repeat="name in names">{{name}}</li> </ul> </div> The order of the days printed is different: FRIDAY

Angular Directive table rows issue

有些话、适合烂在心里 提交于 2019-12-18 12:15:23
问题 I am a beginner Angular programmer, but I am really close to understanding the directives. I create a fiddle here, but I have never used fiddle before, and it is not quite rendering ... the tr-row is a directive. I am trying to loop through the data, and print a directive (row) per record. HTML: <table ng-controller="fiddleCtrl"> <thead> <th>id</th> <th>name</th> <th>description</th> </thead> <tbody> <tr><tr-row ng-repeat="d in data" scdata="d"></tr-row></tr> </tbody> </table> javascript: var

add bootstrap rows during ng-repeat

情到浓时终转凉″ 提交于 2019-12-18 11:11:28
问题 I have a situation where I have a list of data to be displayed in individual panels, Using Bootstrap's grid system, I'd like to take advantage of a wide screen and display several panels horizontally, but on narrow screens have them stack. I'm currently laying things out on the server side with ejs like this, with columns being passed in as a query parameter, typically set to 2 or 3, so each colClass is either col-sm-6 or col-sm-4. <% var colWidth = 12/columns; var colClass = "col-sm-" +

AngularJS: code not working when iterating through object [duplicate]

自作多情 提交于 2019-12-18 09:33:49
问题 This question already has answers here : 'this' vs $scope in AngularJS controllers (7 answers) Closed 3 years ago . I am trying to populate a list of employee objects from my controller empctrl in a template. Here's the controller: app.controller('employeeController', function ($scope, employeeService) { this.employees = {}; this.populateTable = function (data) { this.employees = data; }; var error = function (err) { console.log("Error: " + err); }; // Call Service to List all Employees

How do I generate nested table in one column if it has list of values using angular js?

女生的网名这么多〃 提交于 2019-12-18 07:16:10
问题 index.js var app = angular.module('plunker', []); app.controller('MainCtrl', function($scope) { $scope.name = 'World'; $scope.data =[{"Id":1,"Title":"en-US","Description":"UnitedStates","MyValues":[{"Id":100,"Value":"Save"}]}, {"Id":1,"Title":"en-UK","Description":"UK","MyValues":[{"Id":102,"Value":"Delete"}]}] $scope.cols = Object.keys($scope.data[0]); $scope.notSorted = function(obj){ if (!obj) { return []; } return Object.keys(obj); } }); index.html <table border=1> <thead> <tr> <th ng