angularjs-ng-repeat

Angularjs dynamically adding and removing elements using directive

旧时模样 提交于 2019-12-18 07:07:01
问题 I used directive for creating contact form. Initially i create customerForm directive for displaying customer form. In that form i have one button, when we click on add button, called getData function and that function internally used newDirective for displaying ul list. for that i used $compile api for compiling html code. that is fine and its also display list value and remove button when we click on remove button, its called scope.remove() function. But its delete only ones. after that i

Problems with `track by $index` with Angular UI Carousel

半腔热情 提交于 2019-12-18 06:52:58
问题 $index in track by index does not start at zero when pagination is used I have created a carousel using angular ui bootsrap. Since am loading so many images(over 1,000), I used a filter to display 500 pictures in the pagination. .filter('pages', function () { return function (input, currentPage, pageSize) { if (angular.isArray(input)) { var start = (currentPage - 1) * pageSize; var end = currentPage * pageSize; return input.slice(start, end); } }; }) The controller: self.currentPage = 1; self

AngularJS event for when model binding or ng-repeat is complete?

余生颓废 提交于 2019-12-18 04:45:11
问题 We have a large model and it takes a couple seconds for ng-repeat to bind all the items in the model to the form. We would like to show a spinner while it this is happening. Is there some event that fires when binding is complete so we know when to hide the spinner? 回答1: Plunkr: http://plnkr.co/edit/GzzTW4?p=preview Use ng-show on the spinner If you are using 1.2 use ng-if <div ng-controller="Ctrl"> <div ng-show="complete">Complete={{complete}}</div> <div class="thing" ng-repeat="thing in

Applying ng-class based on value

心不动则不痛 提交于 2019-12-18 04:04:30
问题 I have a simple ng-repeat that displays a list of scores and a value of either Positive or Negative. What i am trying to do is when the value is Negative, display a red background CSS class, and when Positive, display a green CSS class. However, for some reason, i am always seeing the red CSS class on my page. HTML: <tr ng-repeat="scores in Test" ng-class="{true: 'warning', false: 'ok'}[scores.Indicator == 'Negative']"> <td>Overall: {{ scores.Indicator }}</td> </tr> CSS: .warning { background

Disabled selected item in Angular for other Select Option Fields of the same Items

回眸只為那壹抹淺笑 提交于 2019-12-18 03:46:09
问题 I've been struggling on this for a while... I'm currently using Angular. Let's say we have five select option fields and that we are iterating through the same list for each one. Our options are: $scope.items = [one, two, three, four, five]; If I choose one, how would I disable the selected option for the remaining select option fields? And if I go to another select option field and select an available item, it then disables that item for all the other fields. Any help or even guidance on how

How do you toggle an active state ng-class in an ng-repeat item using ng-click?

旧时模样 提交于 2019-12-18 03:38:31
问题 <ul> <li data-ng-repeat="image in images" data-ng-click="toggle = !toggle" data-ng-init="toggle=false"> <img data-ng-class="{'active' : toggle}" src="" /> </li> </ul> CSS for 'active' class is from bootstrap. So toggling works, which is almost where I want it; I would like it similar to active states in navigation links, except in my example it's dealing with images so need to worry about url strings, etc. I tried emulating this example found here to no avail (I tried the same logic for

AngularJS: How to change ng-repeat limitTo based on variable?

眉间皱痕 提交于 2019-12-18 02:44:09
问题 I would like to show a different limitTo number on Angular.js ng-repeat, based on a variable. Here is my code: <input type="text" ng-model="search" ng-change="checkNewCard(search)"/> <div ng-repeat="score in scores | filter:search | limitTo:6" ng-hide="search"> ... </div> <div ng-repeat="score in scores | filter:search | limitTo:5" ng-hide="!search"> ... </div> <div new-card name="search" ng-show="showNewCard"></div> and in the controller: $scope.showNewCard = false; $scope.checkNewCard =

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

Angularjs OrderBy on ng-repeat doesn't work

[亡魂溺海] 提交于 2019-12-17 22:26:31
问题 I'm trying to use AngularJS for my first project (a tournaments manager) and the orderBy filter on ng-repeat doesn't work :( I have read all the documentation about that, but nothing to do :/ So, I have vars defined on $scope like that : $scope.order_item = "count_win"; $scope.order_reverse = false; $scope.teams = { 100 : { id: 100, name: "XXX", count_win: 1, count_loose: 2, goal_average: 1, }, 200 : { id: 200, name: "XXX", count_win: 1, count_loose: 2, goal_average: 1, }, [...] }; Now, on my

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