angularjs-ng-repeat

Angular filter by text search and dropdown

久未见 提交于 2019-12-08 02:48:15
问题 I'm having trouble and I can't seem to find an answer. I'm trying to filter using an text input box and a drop down menu. Its for a fantasy football app to give you an idea. Some code below <form class="form-inline search-width"> <input class="search form-control" type="text" ng-model="nameSearch.name"> <select class="form-control" ng-model="nameSearch.position"> <option value="All">All</option> <option value="QB">QB</option> <option value="RB">RB</option> <option value="WR">WR</option>

AngularJS set ng-click function with scope variables within ng-repeat

让人想犯罪 __ 提交于 2019-12-08 02:41:19
问题 I would like to assign different functions to ng-click within ng-repeat: <button ng-repeat="button in notification.buttons" ng-click="button.fn"> {{button.label}} </button> Controllers: app.controller('MainCtrl', ['$scope', function($scope){ $scope.notification = { ctrl: 'logout', text: 'Logout?', buttons: [ {label:'Yes', fn: 'logout()'}, {label:'No', fn: 'cancel()'}, ], }; }]); app.controller('logout', ['$scope', function($scope){ $scope.logout = function(){ alert('logout'); }; $scope.cancel

AngularJS and php array data

风流意气都作罢 提交于 2019-12-08 01:57:44
问题 I recently started learning AngularJS. When I getting data from the database an array, I using function foreach, so my code is <ul> <?php foreach($Items as $Item):?> <li><?php echo $Item['name'];?></li> <?php endforeach;?> </ul> I use AngularJS because I need sortable list elements. And my code with AngularJS roughly the <script> function PositionsList($scope){ $scope.positions=<?php echo json_encode($Items);?> } </script> <ul> <li ng-repeat="position in positions | filter:query"> <p>{

Angular.Js Performance, large dataset, ng-repeat, html table with filters and two way binding

雨燕双飞 提交于 2019-12-08 01:55:04
问题 So I have a simple layout of a page which includes a panel of filters and a html table of records using ng-repeat. I am using MVC5 and an angularJs controller I may have to deal with up to 100000 records. Filters will occur for most of the columns including dates and text fields The records need to deal with two way binding (user has to select records which will be returned to the server). I'd like get opinions on the best design ideas for this....i.e. Would you load all the data to the

Show a loading screen as background images load in ng-repeat

不打扰是莪最后的温柔 提交于 2019-12-08 00:44:08
问题 I have a list loaded through ng-repeat where each element contains an img tag. I'd like to show some sort of loading indicator (occluding the list items) until every image within every item has finished loading. I guess I would need to hook into some event broadcast by the angular back-img directive but I don't really know where to start here. 回答1: Okay, so I solved my problem. First of all, @Vladimir, you're totally right -- back-img was a directive my colleague wrote, which obscured the

AngularJS nested directives are inserted outside their supposed parent element

别来无恙 提交于 2019-12-07 22:59:47
问题 I'm having trouble understanding how nested directives work with AngularJS. var app = angular.module('plunker', []); app.directive('myTable', function() { return { restrict: 'E', template: [ '<table class="table table-query" ng-show="queries.length">', '<thead>', '<tr>', '<th class="query-name">Name</th>', '<th class="query-status">Status</th>', '</tr>', '</thead>', '<tbody>', '<my-row ng-repeat="query in queries track by $index"', 'query="query">', '</my-row>', '</tbody>', '</table>', ].join

ng-repeat and ng-switch doesn't work on same element

佐手、 提交于 2019-12-07 19:23:03
问题 JS $scope.mode = "test" $scope.array = ['test1', 'test2', 'test3'] HTML <div ng-switch on="mode"> <div ng-repeat="item in array" ng-switch-when="test"> Test {{item}} </div> </div> When I do this the above, the output I get is Test Test Test It can't seem to access item. If I remove the ng-switch-when then it works fine. 回答1: It is because ng-switch creates a child scope and same applies for ng-repeat. ng-repeat runs at priority 1000 and ng-switch at 800 . So the child scope created by ng

Get ng-repeat complete in angular directive

二次信任 提交于 2019-12-07 17:26:41
问题 In the code below, how does the angular directive 'myscroll' know what ng-repeat elements are being created? <myscroll> <div ng-repeat="a in arr">{{a}}</div> </myscroll> I know that the $last event is not fired to the parent directive, how can I solve this? myapp.directive("myscroll", function () { return{ restrict: "E", transclude: true, template: "<span class='left'></span><div class='mask' ng-transclude></div><span class='right'></span>", link: function (scope, element, attr) { scope.

How to insert $compile'd HTML code inside the directive without getting $digest recursion error?

风格不统一 提交于 2019-12-07 15:20:37
问题 I have a directive that, depending on the ng-repeat item data (from the database), build custom HTML with a switch case: app.directive('steps', function($compile){ return { 'restrict': 'A', 'template': '<h3>{{step.name}}</h3><ul ng-repeat="opt in step.opts"><div ng-bind-html-unsafe="extra(opt)"></div></ul>', 'link': function($scope, $element){ $scope.extra = function(opt){ switch ($scope.step.id){ case 1: return "<div>Some extra information<select>...</select></div>" case 2: return "<div>

Remove duplicate from ng-repeat [duplicate]

不羁岁月 提交于 2019-12-07 14:28:23
问题 This question already has answers here : How to get unique values in an array (29 answers) Closed last year . I have a very simple array that has duplicate values. My array is like this: $scope.type= ["Bar", "Pie", "Line", "Line", "Line", "Line", "Line", "Line", "map", "Line", "Bar", "Pie", "Pie", "Pie", "Pie", "Pie", "Pie", "Pie"] in my ng-repeat, I have this condition ng-repeat = types in type track by $index How can I display only the unique values from my array in ng-repeat? 回答1: You can