angularjs-ng-repeat

Sortable table columns with AngularJs

假装没事ソ 提交于 2019-11-29 03:06:25
问题 I'm trying to sort a table of data which is populated from a JSON source. The code I have is as follows: HTML: <div ng-app="myApp"> <div ng-controller="PurchasesCtrl"> <table cellspacing="0"> <tr class="first"> <th class="first" ng:click="changeSorting(purchases.date)">Date</th> <th ng:click="changeSorting(purchases.text)">Description</th> <th ng:click="changeSorting(purchases.price)">Amount</th> <th ng:click="changeSorting(purchases.availability)">Status</th> </tr> <tr ng-repeat="purchase in

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

假装没事ソ 提交于 2019-11-29 02:45:49
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 to do this would be appreciated. Thanks There are two possible solutions that you may want, and it

using ng-repeat inside another ng-repeat

╄→гoц情女王★ 提交于 2019-11-29 02:17:43
问题 I'm developing a page where I need to show some boxes (using ng-repeat ) that contains info of channels and where it will be shown (which are cities). The problem I am facing is when I repeat the second ng-repeat : <table class="table table-condensed" ng-init="nitsCh = [objsCh[$index].nit]"> This should get the $index of first ng-repeat and create a new array with the places the channels will be shown. And it does exactly that. But, when I apply the second ng-repeat using this array, it doesn

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

人走茶凉 提交于 2019-11-29 02:11:57
<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 images): ng-class to highlight active menu item based on ng-repeat. AngularJS If someone could point me in

Pass parameter to Angular ng-include

被刻印的时光 ゝ 提交于 2019-11-29 02:03:46
问题 I am trying to display a binary tree of elements, which I go through recursively with ng-include. What is the difference between ng-init="item = item.left" and ng-repeat="item in item.left" ? In this example it behaves exactly the same, but I use similiar code in a project and there it behaves differently. I suppose it's because of Angular scopes. Maybe I shouldn't use ng-if, please explain me how to do it better. The pane.html is: <div ng-if="!isArray(item.left)"> <div ng-repeat="item in

Filter ng-options from ng-options selection

走远了吗. 提交于 2019-11-29 01:37:10
问题 I'm hoping to solve three problems... In my app page I have one select for states and another for counties. For states I have: <select ng-model="filter.stateID" ng-options="item.stateID as item.state for item in st_option"> </select> Data: [ { state="California", stateID="5"}, { state="Arizona", stateID="3"}, { state="Oregon", stateID="38"}, { state="Texas", stateID="44"}, { state="Utah", stateID="45"}, { state="Nevada", stateID="29"} ] For my County select I have: <select ng-model="filter

how to pass angular js variable inside onclick function as parameter

五迷三道 提交于 2019-11-29 01:27:48
I have tried to pass AngularJS variable as argument value inside onclick() to call javascript function. Can anyone guide me on how to do it? My code: <div onclick="deleteArrival({{filterList.id}})" class="table-icon deleteIcon">{{filterList.id}}</div> SixteenStudio You should be using ng-click, there is no reason to use onclick as angular provides you with this functionality <div ng-click="deleteArrival(filterList.id)" class="table-icon deleteIcon">{{filterList.id}}</div> You should then move your function into your AngularJS Controller, and bind it to the scope $scope.deleteArrival = function

Assigning ng-model to checkboxes generated by ng-repeat

两盒软妹~` 提交于 2019-11-28 23:33:53
I have set up a json containing a list of countries with an ID and Country code attached: It looks like this: $scope.countries = [ {"name":"Afghanistan","id":"AFG","country-code":"004"}, {"name":"Åland Islands","id":"ALA","country-code":"248"}, {"name":"Albania","id":"ALB","country-code":"008"}, {"name":"Algeria","id":"DZA","country-code":"012"} ] I then use the ng-repeat directive to create checkbox inputs for every country. <div ng-repeat="country in countries"> <label><input type="checkbox" ng-model="{{country.id}}" ng-true-value="'{{country.name}}'" ng-false-value="''">{{country.name}}<

ng-repeat a single element over nested objects

徘徊边缘 提交于 2019-11-28 23:27:25
Say I have an object with keys corresponding to products and values corresponding to objects which in turn have keys corresponding to price points at which those products have sold, and values corresponding to amount sold. For example, if I sold 10 widgets at $1 and 5 widgets at $2, I'd have the data structure: { 'widget': {'1': 10, '2': 5} } I'd like to loop over this structure and generate rows in a table such as this one: thing price amount --------------------- widget $1 10 widget $2 5 In Python it's possible to nest list comprehensions to traverse lists data structures like this. Would

Recursion with ng-repeat in Angular

倖福魔咒の 提交于 2019-11-28 23:13:19
I have the following data structure for items in my sidemenu, in an Angular app based on a paid-for web site theme. The data structure is my own, and the menu is derived from the original menu view with all items in the ul hard coded. In SidebarController.js : $scope.menuItems = [ { "isNavItem": true, "href": "#/dashboard.html", "text": "Dashboard" }, { "isNavItem": true, "href": "javascript:;", "text": "AngularJS Features", "subItems": [ { "href": "#/ui_bootstrap.html", "text": " UI Bootstrap" }, ... ] }, { "isNavItem": true, "href": "javascript:;", "text": "jQuery Plugins", "subItems": [ {