ng-repeat

AngularJS, ngRepeat, and default checked radio button

白昼怎懂夜的黑 提交于 2019-12-01 01:39:59
问题 When using ngRepeat, 3 pairs of radio buttons can be created using the following code: <div ng-repeat="i in [1,2,3]"> <input type="radio" name="radio{{i}}" id="radioA{{i}}" value="A" checked> A <input type="radio" name="radio{{i}}" id="radioB{{i}}" value="B"> B </div> For some reason, only the last pair of radio buttons generated by ngRepeat is affected by the checked attribute. Is this because of the way AngularJS updates the view? Is there a way to fix it? 回答1: That is possibly because when

How to disable option in Angular JS?

时光怂恿深爱的人放手 提交于 2019-12-01 01:04:27
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> You need to use ng-options here which has way to disable the options <select ng-model="year" ng-options="year.id disable when

Editable Table Cell in AngularJS

我们两清 提交于 2019-11-30 22:21:52
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 editable. I am now stuck for the next stage, every cell within the table is editable. I have read a

Get old value and new value from dropdown

泄露秘密 提交于 2019-11-30 20:32:51
I'm trying to simply get the previous value, and the newly selected value from a drop-down. In this example, the drop-down is pre-populated with the current group the user is assigned. When the drop-down is changed, I want to be able to return the old value and the new value. I can already get the old value, but I don't know how to return the new value. Controller Code: // User Object userAccess = [{"user_name":"dodsosr11", "group_level":1, "user_id":500, "group_id":10, "group_name":"Conferences_Admins"}, {"user_name":"keatikj09", "group_level":1, "user_id":250, "group_id":10, "group_name":

Angularjs: greater than filter with ng-repeat

烈酒焚心 提交于 2019-11-30 20:31:28
I'm applying a greater than filter to a ng-repeat tag. I wrote the following custom filter function: $scope.priceRangeFilter = function (location) { return location.price >= $scope.minPrice; }; and I use it in the following HTML code: <div ng-repeat="m in map.markers | filter:priceRangeFilter"> What is the best way to trigger a refresh of the ng-repeat tag when $scope.minPrice is updated? It should be automatic. When $scope.minPrice is changed, the repeater will be automatically updated. function Ctrl($scope, $timeout) { $scope.map = [{ name: 'map1', price: 1 }, { name: 'map2', price: 2 }, {

Angularjs dynamic directive inside ngrepeat

耗尽温柔 提交于 2019-11-30 20:24:38
Look at example: $scope.fields = [{ name: 'Email', dir : "abc" }, { name: 'List', dir : "ddd" }]; app.directive('abc', function () {}); app.directive('ddd', function () {}); <table class="table table-hover"> <tr ng-repeat="p in fields"> <input {{p.dir}} ngmodel="p" /> </tr> </table> How can I write code, that p.dir will dynamically convert to a directive ? My example: hhttp://jsbin.com/vejib/1/edit Khanh TO Try this directive: app.directive('dynamicDirective',function($compile){ return { restrict: 'A', replace: false, terminal: true, priority: 1000, link:function(scope,element,attrs){ element

AngularJS - Append element to each ng-repeat iteration inside a directive

淺唱寂寞╮ 提交于 2019-11-30 16:30:03
I'm using a ng-repeat inside a <tr> element together with a directive. Html: <tbody> <tr ng-repeat="row in rows" create-table> <td nowrap ng-repeat="value in row | reduceString>{{value}}</td> </tr> </tbody> Directive: app.directive('createTable', function () { return { link: function (scope, element, attrs) { var contentTr = scope.$eval('"<tr ng-show="false"><td>test</td></tr>"'); $(contentTr).insertBefore(element); } } } ); Although I can append a new <tr> element to each iteration, I'm not able to get angular code executed after it's been added to the DOM (for example the ng-show inside the

angularjs ng-repeat ordering string arrays in numerical order

你离开我真会死。 提交于 2019-11-30 16:25:56
I have a list of post with ids like 1,2,3,4,5,6,7,8,9,10,11,12 (json format) The ids are of type String. But I would like to order it according to its numerical order Normal orderBy:'fiche.id' the list is displayed as below. 1,10,11,12,2,3,4,5,6,7,8,9 I would like the output to be of order - 1,2,3,4,5,6,7,8,9,10,11,12 I guess your ids are strings. A simple solution would be use a no. operation inside order by. So instead ofr orderBy:'id' just use orderBy:'id*1' this will consider the id as no. and sort it according to the numerical order. This is all you need - <div ng-repeat="fiche in fiches

Accessing the nested Arrays using ng-repeat in angularjs

女生的网名这么多〃 提交于 2019-11-30 14:09:59
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 anyone point me to what I'm missing? The problem is you are trying to repeat a list of li elements

AngularJS - Manipulating the DOM after ng-repeat is finished

蓝咒 提交于 2019-11-30 11:40:44
问题 I'm experiencing some problems regarding manipulation of the DOM after looping through the data. We have a jQuery slider plugin that is tied to data and works normally, but when using ng-repeat , we have to wrap its initialization with $timeout for it to work — and now that isn't even working. I think using $timeout is unreliable, which makes for a bad fix. In jQuery I could use $(document).ready() — which was solid, but using angular.element(document).ready() doesn't seem to work either. The