ng-repeat

How to get selected value from ng-repeat

梦想与她 提交于 2019-12-19 05:08:10
问题 This is my code. I m getting data through ng-repeat and showing it as shown in below code. What I want is if I click on either of the name then it should alert me with that name. How can I achieve this?? var myfriend = angular.module('myfriend',[]); myfriend.controller('myfriendController', function($scope) { $scope.record = [ { "id" : "01", "firstname" : "Mohan ", "middlename" : "K", "lastname" : "Futterkiste1" },{ "id" : "04", "firstname" : "Rohan ", "middlename" : "A", "lastname" :

How to disable option in Angular JS?

白昼怎懂夜的黑 提交于 2019-12-19 04:47:43
问题 I have ng-repeat option: <option ng-repeat="year in data.dateList.year" value="{{year.id}}" ng-disabled="(year.id < 2015) ? true : false"> You can see ng-disabled="(year.id < 2015) ? true : false" Why my option is not disabled if year.id less than 2015? This is my new code: <div class="itm" ng-repeat="a in range(num) track by $index"> <option ng-repeat="year in data.dateList.year" ng-disabled="(year.id) < formData.beginYear[$index]"> {{year.value}} </option> </div> 回答1: You need to use ng

Editable Table Cell in AngularJS

柔情痞子 提交于 2019-12-19 03:43:06
问题 I am extremely new to most of this so my apologies, my code is mostly beg borrowed and fudged from this forum and I am learning as I go along. Currently I am trying to replicate a heater timing system, each day has 6 switches which can alter the temperature. I have loaded some example data in via my controller and displayed in a table using ng-repeat, it is not ideal but for the time being it is working and will do what I require. My data is display is static, no formatting or sorting, just

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

Accessing the nested Arrays using ng-repeat in angularjs

倾然丶 夕夏残阳落幕 提交于 2019-12-18 16:49:10
问题 JSFiddle I'm not able to access the array images in the nested collection. Why am I not able to see any output? The model: var obj = [{ "id": "7", "date": "1 Jan", "images": ["507f42c682882", "507e24b47ffdb", "507e2aeca02d5", "507e2b19663a9"] }, { "id": "7", "date": "1 Jan", "images": ["507f42c682882", "507e24b47ffdb", "507e2aeca02d5", "507e2b19663a9"] }]; This is the HTMl with ng-repeat: <ul> <li ng-repeat="img in item"> <br /> <li ng-repeat="img1 in img.images">{{img1}}</li> </li> </ul> Can

AngularJS - ng-repeat to assign/generate a new unique ID

∥☆過路亽.° 提交于 2019-12-17 23:24:19
问题 Im using a simple ng-repeat to generate a list of countries. Within each list is a hidden row/div that can be expanded and collapsed. The issue that i am facing, is that before i introduced Angular into my application, i manually hard-coded the element's ID, for example: <li data-show="#country1"> {{country.name}} has population of {{country.population}} <div id="country1"> <p>Expand/collapse content </div> </li> <li data-show="#country2"> {{country.name}} has population of {{country

angular.js ng-repeat - check if conditional is true then use another collection

拥有回忆 提交于 2019-12-17 20:08:47
问题 I'm wondering is it possible to check what collection to use inside ng-repeat ? For example, in my controller I have 2 arrays of data fetched from server, now I use ng-switch to switch between them, check this jsbin - http://jsbin.com/diyefevi/1/edit?html,js,output The problem is that these li views in my real application are big but very similar.. so I really would like to use 1 ng-repeat instead of 2 . So I wonder if something like ng-repeat="book in if list==='adultBooks' adultBooks else

What is “track by” in AngularJS and how does it work?

对着背影说爱祢 提交于 2019-12-17 19:38:13
问题 I don't really understand how track by works and what it does. My main goal is to use it with ng-repeat to add some precision. 回答1: Using track by to track strings & duplicate values Normally ng-repeat tracks each item by the item itself. For the given array objs = [ 'one', 'one', 2, 'five', 'string', 'foo'] , ng-repeat attempts to track changes by each obj in the ng-repeat="obj in objs" . The problem is that we have duplicate values and angular will throw an error. One way to solve that is

Angular ng-repeat add bootstrap row every 3 or 4 cols

十年热恋 提交于 2019-12-17 02:06:22
问题 I'm looking for the right pattern to inject a bootstrap row class every each 3 columns. I need this because cols doesn't have a fixed hight (and I don't want to fix one), so it breaks my design ! Here is my code : <div ng-repeat="product in products"> <div ng-if="$index % 3 == 0" class="row"> <div class="col-sm-4" > ... </div> </div> </div> But it does only display one product in each row. What I want as final result is : <div class="row"> <div class="col-sm4"> ... </div> <div class="col-sm4"

Angular ng-repeat add bootstrap row every 3 or 4 cols

一笑奈何 提交于 2019-12-17 02:05:14
问题 I'm looking for the right pattern to inject a bootstrap row class every each 3 columns. I need this because cols doesn't have a fixed hight (and I don't want to fix one), so it breaks my design ! Here is my code : <div ng-repeat="product in products"> <div ng-if="$index % 3 == 0" class="row"> <div class="col-sm-4" > ... </div> </div> </div> But it does only display one product in each row. What I want as final result is : <div class="row"> <div class="col-sm4"> ... </div> <div class="col-sm4"