angularjs-ng-repeat

Using Modal Window inside ng-repeat

寵の児 提交于 2019-11-30 05:22:28
I have a ng-repeat and I am trying to add a modal that passes the same scope variable to the modal window. I am able to get the modal window to open but the scope value from ng-repeat is not showing inside the modal. Hopefully my code explains better. This is what I have so far: <div ng-controller="CustomerController"> <div ng-repeat="customer in customers"> <button class="btn btn-default" ng-click="open()">{{ customer.name }}</button> <!--MODAL WINDOW--> <script type="text/ng-template" id="myModalContent.html"> <div class="modal-header"> <h3>The Customer Name is: {{ customer.name }}</h3> <

Angularjs dynamic directive inside ngrepeat

℡╲_俬逩灬. 提交于 2019-11-30 05:16:29
问题 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 回答1: Try this directive: app.directive('dynamicDirective',function($compile){ return { restrict

Sortable table columns with AngularJs

一世执手 提交于 2019-11-30 05:14:15
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 purchases.data"> <td class="first">{{purchase.date}}</td> <td>{{purchase.text}}</td> <td>{{purchase

using ng-repeat inside another ng-repeat

女生的网名这么多〃 提交于 2019-11-30 05:00:44
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't work properly. Said that my html looks like this (PS: I need to use the index value instead of objCh

Group item detail using AngularJs ng-repeat

瘦欲@ 提交于 2019-11-30 04:41:28
问题 I would like to perform a group by function inside of an ng-repeat Given the following data: var items = []; items.push({ id: 1, widgetId: 54, colorId: 45 }); items.push({ id: 2, widgetId: 54, colorId: 72 }); items.push({ id: 3, widgetId: 54, colorId: 29 }); items.push({ id: 4, widgetId: 55, colorId: 67 }); items.push({ id: 5, widgetId: 55, colorId: 29 }); items.push({ id: 6, widgetId: 56, colorId: 29 }); items.push({ id: 7, widgetId: 56, colorId: 72 }); items.push({ id: 8, widgetId: 57,

Simple One way binding for ng-repeat?

て烟熏妆下的殇ゞ 提交于 2019-11-30 04:33:00
I have read some articles that said ng-repeat would led to poor performance if there is over 2000 items, because there are too many two way binding to watch. I am new to angularjs and have trouble understanding the relationship between ng-repeat and two-way binding: Does ng-repeat (like outputting a list of json objects) necessarily create two way binding? Is there a simple way to do ng-repeat using only one way binding? (preferably do not need external module) Cindy Conway Like user1843640 mentioned, if you are on Angular 1.3, you can use one-time-binding, but, just for clarity, you need to

Pass parameter to Angular ng-include

混江龙づ霸主 提交于 2019-11-30 04:11:37
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 [item.left]" ng-include="'Views/pane.html'"> </div> </div> <div ng-if="isArray(item.left)"> {{item.left[0]

Filter ng-options from ng-options selection

心不动则不痛 提交于 2019-11-30 03:58:15
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.countyID" ng-options="item.countyID as item.county for item in co_option"> </select> Data: [ { county=

AngularJS limitTo filter for ngRepeat on an object (used like a dictionary)

こ雲淡風輕ζ 提交于 2019-11-30 03:33:46
问题 Is it possible to use limitTo filter on a ngRepeat directive which is repeating the properties of an Object and not items in an Array. I am aware that the official documentation says that the input to limitTo needs to be an array or a string. But wondering if there's a way to get this to work. Here's a sample code: <li ng-repeat="(key, item) in phones_dict |orderBy:'-age'| limitTo:limit_items"></li> And $scope.phones_dict is an Object like { item_1: {name:"John", age: 24}, item_2: {name:"Jack

add bootstrap rows during ng-repeat

末鹿安然 提交于 2019-11-30 02:48:07
I have a situation where I have a list of data to be displayed in individual panels, Using Bootstrap's grid system, I'd like to take advantage of a wide screen and display several panels horizontally, but on narrow screens have them stack. I'm currently laying things out on the server side with ejs like this, with columns being passed in as a query parameter, typically set to 2 or 3, so each colClass is either col-sm-6 or col-sm-4. <% var colWidth = 12/columns; var colClass = "col-sm-" + colWidth; %> <% for(var i=0; i<contestData.classData.length; i++) {%> <% if ((classCount % columns) == 0) {