angularjs-ng-repeat

Angular passing scope to ng-include

邮差的信 提交于 2019-12-17 15:39:04
问题 I have a controller that I wrote that I use in multiple places in my app with ng-include and ng-repeat , like this: <div ng-repeat="item in items" ng-include="'item.html'" ng-controller="ItemController" ></div> In the controller/template, I expect the item value to exist, and the whole thing is built around this idea. Now, though, I need to use the controller in a slightly different way, without the ng-repeat , but still need to be able to pass in an item . I saw ng-init and thought it could

How to catch memory leaks in an Angular application?

最后都变了- 提交于 2019-12-17 15:16:55
问题 I have a webapp written in AngularJS which basically polls an API to two endpoints. So, every minute it polls to see if there is anything new. I discovered that it has a small memory leak and I've done my best to find it but I'm not able to do it. In the process I've managed to reduce the memory usage of my app, which is great. Without doing anything else, every poll you can see a spike in the memory usage (that's normal) and then it should drop, but it's always increasing. I've changed the

ng-repeat specify a starting index

折月煮酒 提交于 2019-12-17 10:56:12
问题 How can I specify an index where an ng-repeat directive is going to start instead of zero? I have a set of results and I just need to specify the starting one, which is different from zero. 回答1: No need to code anything, angular has done this with the existing built-in limitTo filter. Just use a negative limit. From the docs for the limit argument: The length of the returned array or string. If the limit number is positive, limit number of items from the beginning of the source array/string

AngularJS filter based on array of strings?

让人想犯罪 __ 提交于 2019-12-17 10:42:51
问题 I'm having a hard time wrapping my head around how to go about doing an Angular filter to solve a problem that I'm running into. Here's a basic example of my data structure, an array of tasks: var tasks = [ { Title: "This is a task title", Tags: ["Test","Tag","One","Two","Three"] }, { Title: "Another test tag title", Tags: ["Some", "More", "Tags"] }, { Title: "One more, why not", Tags: ["I","Like","Dirt"] }, { Title: "Last one!", Tags: ["You","Like","Dirt"] } ]; So each object has an array of

Highlighting a filtered result in AngularJS

家住魔仙堡 提交于 2019-12-17 10:23:38
问题 I'm using a ng-repeat and filter in angularJS like the phones tutorial but I'd like to highlight the search results in the page. With basic jQuery I would have simply parsed the page on key up on the input, but I'm trying to do it the angular way. Any ideas ? My code : <input id="search" type="text" placeholder="Recherche DCI" ng-model="search_query" autofocus> <tr ng-repeat="dci in dcis | filter:search_query"> <td class='marque'>{{dci.marque}} ®</td> <td class="dci">{{dci.dci}}</td> </tr>

AngularJS - Filter empty objects

北慕城南 提交于 2019-12-17 09:40:26
问题 I have a $scope.myData object that contain a chunk of data. What i am trying to do is display the data but filter out the nulls and empty strings: $scope.myData = [ { "ID" : "001", "Message" : "test test test test" }, { "ID" : "002", "Message" : "test test test test" }, { "ID" : "003", "Message" : "test test test test" }, { "ID" : "004", "Message" : "test test test test" }, { "ID" : "005", "Message" : " " }, { "ID" : "006", "Message" : "test test test test" }, { "ID" : "007", "Message" :

Angular.js ng-repeat filter by property having one of multiple values (OR of values)

岁酱吖の 提交于 2019-12-17 09:16:29
问题 Is it possible to filter an array of objects, such that the value of property can be either of a few values (OR condition) without writing a custom filter This is similar to this problem - Angular.js ng-repeat :filter by single field But instead of <div ng-repeat="product in products | filter: { color: 'red' }"> is it possible to do something like this <div ng-repeat="product in products | filter: { color: 'red'||'blue' }"> for a sample data as follows- $scope.products = [ { id: 1, name:

Angular.js ng-repeat filter by property having one of multiple values (OR of values)

狂风中的少年 提交于 2019-12-17 09:16:06
问题 Is it possible to filter an array of objects, such that the value of property can be either of a few values (OR condition) without writing a custom filter This is similar to this problem - Angular.js ng-repeat :filter by single field But instead of <div ng-repeat="product in products | filter: { color: 'red' }"> is it possible to do something like this <div ng-repeat="product in products | filter: { color: 'red'||'blue' }"> for a sample data as follows- $scope.products = [ { id: 1, name:

Using ng-repeat to generate select options (with Demo)

老子叫甜甜 提交于 2019-12-17 07:53:21
问题 controller: $scope.send_index = function(event, val){ console.log(val); $scope.variable = 'vm.areas['+val+'].name'; console.log( $scope.variable ); }; and this is in the view: <select ng-model="vm.areas"> <option ng-repeat="area in vm.areas" ng-value="area" id="{{area}}" ng-click="send_index($event, $index)">{{area.name}} </select> <input value="{{variable}}"> where "vm" is my model. Expression inside of an expression (Angular) my problem is that i need to have an {{array[]}}, with the index

How to use “ng-repeat” within template of a directive in Angular JS?

谁说我不能喝 提交于 2019-12-17 07:10:29
问题 I'm new to Angular JS and I am trying to create a custom directive that will be used as below: <div linkedlist listcolumns="{{cashAccountsColumns}}"></div> Corrps. controller will be: $scope.cashAccountsColumns = [ {"field": "description", "title": "Description"}, {"field": "owner", "title":"Owner"}, {"field": "currentBalance", "title":"Current Balance" } ]; And the directive code is: return { restrict : 'EA', transclude : false, templateUrl : 'html/linkedlist.html', scope: { listcolumns: "@"