angularjs-ng-repeat

Angular filter and order elements on click

狂风中的少年 提交于 2019-12-02 21:22:44
I'm trying to filter a list of items (grabbed from JSON) onclick. I pull the data once from the server then would like to filter/order the elements using Angular. Here is my plunker: http://plnkr.co/edit/glSz1qytmdZ9BQfGbmVo?p=preview Tabs -- How could I filter/sort the items onclick? "Recent" would be sorted by date and "Popular" would be sorted by views. Categories -- I'm using ng-click to grab the category value although not sure how to update the filter dynamically (using the value passed onclick). Thanks I would wrap the entire functionality inside a parent controller with the tab change

AngularJS not refreshing ngRepeat when updating array

风流意气都作罢 提交于 2019-12-02 20:05:23
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 within $scope.$apply(), I got a "$digest already in progress" error. Wrapping that into $timeout doesn

ng-repeat filter on boolean

与世无争的帅哥 提交于 2019-12-02 19:55:13
I am trying to filter on a boolean value in an ng-repeat. List of unregistered users: <h3>Unregistered Users</h3> <div ng-repeat="user in users | filter:!user.registered"> <div class="row-fluid"> <div class="span2"> {{user.name}} </div> </div> </div> List of registered users: <h3>Registered Users</h3> <div ng-repeat="user in users | filter:user.registered"> <div class="row-fluid"> <div class="span2"> {{user.name}} </div> </div> </div> Is there a good way to filter based on registered and !registered. filter by obj expression: <h3>Unregistered Users</h3> <div ng-repeat="user in users | filter:

Angularjs, Applying Action on Selected Checkboxes in Table

拥有回忆 提交于 2019-12-02 19:36:35
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. Yoshi An easy way would be to change your students list to: $scope.students = [ {Rollno: "1122",Name: "abc",Uni: "res", selected: false}, {Rollno: "2233",Name: "def",Uni: "tuv",

Use href in an AngularJS ng-repeat div

旧巷老猫 提交于 2019-12-02 19:11:50
问题 I'm trying to insert a href link inside a div that uses ng-repeat. This href link needs to be different from each div created with ng-repeat, its value being part of AngularJS $scope variable. Here is my JS code: var app = angular.module('test', []); app.controller('MainCtrl', function($scope) { var database = firebase.database(); database.ref(`trips/${userid}/trips`).once('value') // will return you all the photo objects inside the `tripId` .then(photosSnap => { var trips = []; photosSnap

trigger function after ng-repeat

妖精的绣舞 提交于 2019-12-02 18:46:20
问题 I am new to Angular, and I would like to do a really basic example. After displaying some data with a ng-repeat , I would like to use some of those data with javascript functions. But I don't know when to execute the javascript, because I don't when angular will finish to display my data. Here is a fiddle: I try to show an alert with the function getAssign3 some data displayed by Angular. When should I call this function ? Code: <div ng-app="Test"> <h1>Results Table</h1> <div ng-controller=

Avoid using extra DOM nodes when using nginclude

Deadly 提交于 2019-12-02 17:35:29
I'm struggling to wrap my mind around how to have an ng-include not use an extra DOM element as I'm building an angular app from a plain-HTML demo. I'm working with pretty slim HTML with fully developed, tightly DOM-coupled CSS (built from SASS) and refactoring is something I want to avoid at all costs. Here's the actual code: <div id="wrapper"> <header ng-controller="HeaderController" data-ng-class="headerType" data-ng-include="'/templates/base/header.html'"> </header> <section ng-controller="SubheaderController" data-ng-class="subheaderClass" ng-repeat="subheader in subheaders" data-ng

Angular Search for value in JSON and display corresponding data

我是研究僧i 提交于 2019-12-02 16:52:36
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, $http, getDataService) { $scope.findValue = function(enteredValue) { alert("Searching for = " +

Two Different JSON sources, Update at Different Times; Use Result in ng-Repeat List

大兔子大兔子 提交于 2019-12-02 16:44:22
问题 I am trying to create a status list from two separate JSON sources. The list will display general info from the first source, and show a status color based on the number of people in the second source. The first source contains general data that will not be changing much (i.e. feed name, version, description) and likely called only two times a day. See code example below: /metadata { data: [ { "feedName": "Feed 1", "version": "000001", "location": "1234 Main Street, New York, New York"

AngularJS - Model not updating on selection of radio button generated by ng-repeat

喜欢而已 提交于 2019-12-02 16:43:12
I am generating a bunch of radio buttons using ng-repeat, and then trying to update a model when one of them is selected. This doesn't appear to be working. The same markup works just fine when the radio inputs are hardcoded as opposed to being generated by ng-repeat. This works: <input type="radio" ng-model="lunch" value="chicken" name="lunch"> <input type="radio" ng-model="lunch" value="beef" name="lunch"> <input type="radio" ng-model="lunch" value="fish" name="lunch"> {{lunch}} This doesn't: <input type="radio" ng-model="lunch" ng-repeat="m in meat" value="m" name="lunch"> {{lunch}} See