angularjs-ng-repeat

Custom directive value with bindonce in Angularjs

纵饮孤独 提交于 2019-12-06 12:59:08
I got a ng-repeat with thousands of item in it, so I decided to tryout bindonce to reduce the number of watches. But I couldn't figure out how to use it properly. So now I got the following code: <div ng-repeat="card in cards"> <div class="item-box" draggable="{{card.category}}" itemId="{{card._id}}"> <img ng-src="{{card.image}}" width="100%" height="100%"> </div> </div> As I read in the bindonce doc , I should add the directive and use the bo-* directives, so I fugured out this: <div ng-repeat="card in cards" bindonce> <div class="item-box" draggable="{{card.category}}" itemId="{{card._id}}">

Structure issues using ng-repeat with Bootstrap and AngularJS

匆匆过客 提交于 2019-12-06 12:54:17
问题 I'm building an app with Bootstrap and AngularJS. At some point I have an ng-repeat on a col-md-3, listing products. My problem is that I want to be able to insert a collapse into the grid, but as the columns are automatically generated, I don't really know how to do it. Here's a diagram to understand it better: First, the grid of .col-md-3 is populated from the ng-repeat. And what I'm trying to achieve, is to add a .col-md-12 that appears right under the row of the .col-md-3 that gets

accordion with ng-repeat and ng-bind-html won't work

本小妞迷上赌 提交于 2019-12-06 12:00:00
I'm trying to use accordion and html content in this way: <accordion> <accordion-group ng-repeat="item in items"> <accordion-heading> <a class="btn btn-primary btn-block btn-elenco"> <img postsrc="img/flag/flag_{{item.index}}.jpg"> </a> </accordion-heading> <p ng-bind-html="item.content"></p> </accordion-group> </accordion> AND var items = []; for(var i=0;i<10;i++){ var content = "<div>TEST</div>"; items.push({index:i,content:content}); } $scope.items = items; var app = angular.module('MyApp',['ngSanitize','ui.bootstrap']); Accordion works but html isn't rendered into p tag. What could be the

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

微笑、不失礼 提交于 2019-12-06 11:04:45
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 browser upfront. If not when would more data be requested from the server. If all upfront should two arrays

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

落花浮王杯 提交于 2019-12-06 10:32:55
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 = function(){ alert('cancel'); }; }]); If I put button.fn in double curlies ng-click="{{button.fn}}"

Angular.js more complex conditional loops

﹥>﹥吖頭↗ 提交于 2019-12-06 09:47:59
问题 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

ng-repeat only objects with specific property value - custom filter?

梦想的初衷 提交于 2019-12-06 07:54:55
So say I have a JSON object 'user' with some basic properties like: 'name', 'address', 'role', etc. I want the ng-repeat to only spit out the objects in which the property 'role' equates to 'administrator'. How would I go about doing that? I'm thinking something like a custom filter, or possibly making a scope variable where I put the matching objects in an array, and then repeat through them. What is the best practice for this case? Thanks. The built in filter can handle this case... <div ng-repeat="user in users | filter : {role: 'administrator'} : true"> ... </div> 来源: https://stackoverflow

How do you execute directive code after rendering?

你。 提交于 2019-12-06 07:10:38
问题 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",

Angular filter by text search and dropdown

北慕城南 提交于 2019-12-06 06:50:47
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> <option value="TE">TE</option> <option value="DEF">DEF</option> <option value="K">K</option> </select> {

AngularJS nested directives are inserted outside their supposed parent element

穿精又带淫゛_ 提交于 2019-12-06 06:48:31
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(''), scope: { queries: '=' }, controller: function() { }, link: function(scope, element) { } }; });