angularjs-ng-repeat

Group ng-repeat items

廉价感情. 提交于 2019-12-04 23:11:51
问题 I have an array of items items . I would like to use the ng-repeat directive or something similar, to group n items together. For instance: I would like items=['a', 'b', 'c', 'd', 'e', 'f', 'g'] to be rendered in groups of 3 to be rendered as: <div class="row"> <div class="col-sm-4">a</div> <div class="col-sm-4">b</div> <div class="col-sm-4">c</div> </div> <div class="row"> <div class="col-sm-4">d</div> <div class="col-sm-4">e</div> <div class="col-sm-4">f</div> </div> <div class="row"> <div

Angular JS: ng-repeat with dynamic ng-model

爱⌒轻易说出口 提交于 2019-12-04 22:09:01
问题 I have this working piece of code that is repeated multiple times, hence would be great for a ng-repeat loop. For example, two instances of my code are the following. <div> <input type="text" ng-model="searchParamaters.userName" placeholder="User Name"/> <i class="fa fa-times" ng-click="resetSearchField(filterParamDisplay[0].param)" ng-show="showParam(filterParamDisplay[0].param)"></i> </div> <div> <input type="text" ng-model="searchParamaters.userEmail" placeholder="User Email"/> <i class=

Angular-slick ng-repeat $http get

蓝咒 提交于 2019-12-04 20:53:08
问题 I've been trying all the week end to display data (that I fetch with $http.get ) in the slick angular carousel using ng-repeat , in vain... I've read about the well known issue: here and here. I tried to use the init-onload and data attributes, in vain... HTML: <div ng-controller="LandingCtrl as ctrl"> ... <slick init-onload=true data="ctrl.products"> <div ng-repeat="product in ctrl.products"><img src="{{product.image}}" alt="{{product.title}}"></div> </slick> ... </div> JS : angular.module(

How to dynamically add input rows to view and maintain value in angularjs ng-model as array item

放肆的年华 提交于 2019-12-04 20:41:06
I have a situation where I want the user to dynamically add <input> rows when they want to enter a new item. As shown below, the user clicks the "Add Input Item" button and a new input element is added where the user may add text. I'm trying to associate each input element value to the model $scope.items (an array) in app.js . In my index.html , I load the $scope.items using an ng-repeat . What I do not understand is how I can get each input/row to automatically be added to & managed by the model defined as $scope.items . Is it possible to map each input element to an ng-model that relates to

AngularJS : Remove empty select option in angular ng-repeat

陌路散爱 提交于 2019-12-04 18:01:27
问题 I am using ng-repeat to render options with different value and text here, and also setting the default one.But again angular adds an empty undefined option. <select ng-model="newItem.financial_year_id" required style="min-width:180px;"> <option ng-repeat="financial in account_year" value="{{financial.id}}" ng-selected="financial.status=='Active'">{{financial.financial_year}}</option> </select> Now the active one is selected but the empty option still rendering. 回答1: Try ng-options instead:

Angular.js more complex conditional loops

允我心安 提交于 2019-12-04 16:58:19
The goal is to create this <h3>11.4.2013</h3> <ul> <li>entry 1</li> <li>entry 2</li> <li>entry 3</li> </ul> <h3>10.4.2013</h3> <ul> <li>entry 4</li> <li>entry 5</li> <li>entry 6</li> </ul> from this [ { "name": "entry1", "date": "11.4.2013" }, { "name": "entry2", "date": "11.4.2013" }, { "name": "entry3", "date": "11.4.2013" }, { "name": "entry4", "date": "10.4.2013" }, { "name": "entry5", "date": "10.4.2013" }, { "name": "entry6", "date": "10.4.2013" } ] The problem is that ng-repeat would have to be on li so I wouldn't never be able to do this using ng-repeat, is that right? I found this

angular js multiple checkbox with custom filters

我的未来我决定 提交于 2019-12-04 16:06:30
can some one help me in building angular js customfilter. i have built two dynamic filters(brands and Merchants) from the records(Json data) to filter the records with multiple check boxes. now i need to filter records based on checkboxes checked. Initially all the checkboxes should be unchecked and all the records should be displayed. based on the filters selected the records should be selected. my json data is $scope.records = [ { "MerchantName": "Fashion and You", "BrandList": " Nike, Fila", "Description": "Fashion and You Store" }, { "MerchantName": "Fashion and You", "BrandList": " Levis,

How do you execute directive code after rendering?

末鹿安然 提交于 2019-12-04 15:56:43
I'm trying to build a directive that runs after a nested ng-repeat has completed rendering. Here's what I've tried (fiddle) : The HTML: <div ng-app="MyApp" ng-controller="MyCtrl"> <ul my-directive> <li ng-repeat="animal in animals">{{animal}}</li> </ul> </div> And the JavaScript: angular.module("MyApp", []) .directive("myDirective", function () { return function(scope, element, attrs) { alert(element.find("li").length); // 0 }; }); function MyCtrl($scope) { $scope.animals = ["Dog", "Cat", "Elephant"]; } The linking function in my custom directive runs before all of the <li> elements have been

AngularJS & JSON - Obtain Value from Previous & Next Object

倖福魔咒の 提交于 2019-12-04 14:35:42
问题 Background: I have created an AngularJS test app which, obtains data from a JSON file, which is separated into categories and within each category is an employee card which is displayed through ng-repeat. These categories can then be viewed utilising a slider (using bxSlider). Aim: With bxSlider you can use custom Next/Previous buttons, what I wanted to achieve was to dynamically display the relevant category names in the Next/Previous buttons (please see annotation link below - my level does

Angular: Getting list with ng-repeat with dividers / separators

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 13:17:15
Still pretty new with Angular, just finding my way around. I'm using ng-repeat to output an alphabetised list of names. I'd like to add dividers within this list that act as labels. Example: -------- A -------- Author 1 Author 2 -------- B -------- Author 3 Author 4 etc My thinking is to use nested ng-repeats to loop through the alphabet, getting an object with the authors for that specific letter with a second ng-repeat. Here's what I have so far: <div data-ng-repeat="letter in alphabet"> <div class="item item-divider"> {{letter}} </div> <ul> <li data-ng-repeat="speaker in GetSpeakers(letter)