angularjs-ng-repeat

AngularJS not refreshing ngRepeat when updating array

白昼怎懂夜的黑 提交于 2019-12-03 06:23:35
问题 I'm having serious troubles understanding AngularJS sometimes. So I have a basic array in my controller like $scope.items = ["a","b","c"] I'm ngRepeating in my template over the items array ng-repeat="item in items". Super straightfoward so far. After a couple of UX actions, I want to push some new stuff to my array. $scope.items.push("something"); So, 50% of the time, the new element is added to the view. But the other 50%, nothing happens. And it's like super frustrating; bc if I wrap that

Angularjs, Applying Action on Selected Checkboxes in Table

不想你离开。 提交于 2019-12-03 06:11:41
问题 Im trying to Learn AngularJS and im implementing this Checkboxes that when i some checkboxes from the Grid and click the Remove Button then the Data from Table Should Be removed of Selected CheckBoxes. I tried but cant figure out how to implement it. Please see my this code on Plunker. http://plnkr.co/edit/e7r65Me4E7OIWZ032qKM?p=preview It would be nice, if you fork and Give Working Example of the Above Plunker. 回答1: An easy way would be to change your students list to: $scope.students = [

$first in ngRepeat

末鹿安然 提交于 2019-12-03 05:28:28
问题 I have an array $scope.items . I want if the item is the $first one of the ngRepeat to add the css class in . Is it something that can be done with angular? Generally how can I handle the booleans in Ajs? <div ng-repeat="item in items"> <div class='' > {{item.title}}</div> </div> 回答1: It should be <div ng-repeat="item in items"> <div ng-class='{in:$first}' > {{item.title}}</div> </div> Look at ng-class directive in http://docs.angularjs.org/api/ng.directive:ngClass and in this thread What is

$index of Object in Array while using ng-repeat and a filter

情到浓时终转凉″ 提交于 2019-12-03 05:20:01
Im fairly new to angular and have been able to get around somewhat. But I cant seem to find the answer to this scenario... I have an array of objects, which I am pulling down from firebase. I am using an ng-repeat for the objects, then displaying data accordingly. I am trying to pass the index as a routeparam to an "edit" controller. In which case I would like to pull the object data as one would anticipate. However, when I filter the ng-repeat I am getting the index of the filtered content. where am I going wrong in finding the true index? .config(['$routeProvider', '$locationProvider',

How do I dynamically build an ng-include src?

寵の児 提交于 2019-12-03 04:24:55
I have the following code: <div ng-repeat="module in modules" id="{{module.Id}}"> <ng-include ng-init="bootstrapModule(module.Id)" src=""></ng-include> </div> I want to be able to build a string in src like so: /modules/{{module.Name}}/{{module.Name}}.tpl.html But I keep hitting roadblocks. I've tried to use a call back function to build it, $scope.constructTemplateUrl = function(id) { return '/modules/' + id + '/' + id + '.tpl.html'; } But this gets called over & over & over and it doesn't seem to like that. I've also tried to construct it like so: ng-src="/modules/{{module.Id}}/{{module.Id}}

How to delay ngAnimate in ngRepeat

孤街醉人 提交于 2019-12-03 03:59:10
问题 When using ngAnimate to fade in each item in ngRepeat, currently all items fade in at the same time. Is it possible for each item to fade in after the previous item has faded to e.g. 50% resulting in a cascading effect? <ul> <li ng-repeat="phone in phones" ng-animate="{enter: 'phone-fade-enter'}"> <img src="{{phone.img}}"> {{phone.name}} </li> </ul> Using ngAnimate it would be nice if it would be possible to delay the animation of each item e.g. like this: <li ng-repeat="phone in phones" ng

How to load more elements with AngularJS?

泄露秘密 提交于 2019-12-03 03:47:25
for a while I am trying to find how to make a load more(elements from an array) button,using Angular. I have 9 elements in array, I use ng-repeat to loop them, and limitTo:3 to output first 3. Questions: 1: is possible to make a load more button using only angular?(load more button is at bottom in example) 2: if not, how to make this work using jQuery? http://plnkr.co/edit/1gHB9zr0lbEBwlCYJ3jQ Thanks! Pankaj Parkar You don't need to think of jQuery, as you could solve this problem easily by using AngularJS itself. You could maintain a variable inside your controller, name it as limit , then

AngularJS: traversing nested arrays

喜你入骨 提交于 2019-12-03 03:41:52
I am working with a nested array with the structure... $scope.items = [{attr1: val1, attr2: val2, items: [{ attr1: val1, attr2: val2, items: [{ ... }, ...] }, ...] }, ...]; which goes into an ng-repeat with ng-include like this <div ng-repeat="item in items" ng-include="'/path/to/template.tpl.html'"></div> and template.tpl.html is <div>{{item.attr1}}<\div> <div>{{item.attr2}}<\div> <div ng-click="fnAddNewItemBelow(item, $parent)"><\div> <div ng-repeat="item in item.items" ng-include="'/path/to/template.tpl.html'"><\div> Now, in the controller, I commonly want to do things like find an item's

Angular Search for value in JSON and display corresponding data

隐身守侯 提交于 2019-12-03 03:23:12
问题 What i am trying to do is simple. A user enters a value, on button click, my JS calls a service to retreive my JSON data and perform a search on the value entered against the JSON and if a match is found, display the 'Owner'. HTML: <div ng-app="myApp"> <div ng-controller="MainCtrl"> <input type="text" ng-model="enteredValue"> </br> <button type="button" ng-Click="findValue(enteredValue)">Search</button> </div> </div> JS: angular.module('myApp', []).controller('MainCtrl', function ($scope,

AngularJS ng-repeat, comma separated with 'and' before the last item

烂漫一生 提交于 2019-12-03 02:40:38
问题 I have a list of items ... $scope.Users =[{ UserName: '' }]; In my view I want to list them like this assuming I have only 4 items in my $scope:Users Username1, Username2, Username3 and Username4 <span data-ng-repeat="user in Users">{{user.Username}}</span>{{$last ? '' : ', '}} The above expression will basically add comma after each item and works fine. My problem is how do I add an and keyword before the last item so it will be like: Username1, Username2, Username3 and Username4 instead of: