Nested ng-repeat in AngularJS with Checkboxes
How do I make an nested ng-repeat in angularjs with checkboxes?
Example of how to render data in nested ng-repeat(s) get the selected items from the nested list in real-time through a change event or looping through the data in the end. What is a nested ng-repeat in angularjs with checkboxes? How do you make a nested ng-repeat in angularjs with checkboxes? This script and codes were developed by Aaron K Saunders on 25 September 2022, Sunday.
Nested ng-repeat in AngularJS with Checkboxes - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Nested ng-repeat in AngularJS with Checkboxes</title>
</head>
<body> <html>
<head> <script src="https://code.jquery.com/jquery.min.js"></script> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script> <meta charset="utf-8"> <title>JS Bin</title>
</head>
<body ng-app="myApp" ng-controller="myCtrl"> <div class="container"> <div class="page-header"> <h2>Nested ng-repeat in AngularJS with Checkboxes</h2> <p> Example of how to render data in nested ng-repeat(s) and get the selected items from the nested list in real-time through a change event or looping through the data in the end. </p> </div> <div style="font-size:larger"> <div ng-repeat="week in myData"> <div ng-repeat="day in week.days"> {{day.templateDay}} <b>Jobs:</b> <br/> <ul> <li ng-repeat="job in day.jobs"> <!-- add ng-change to get realtime updates --> <input type="checkbox" ng-model="job.checked" ng-change="getSelectedItems()"> {{job.name}} </li> </ul> </div> <div> <!-- add button to get changes at the end --> <p> </p> <button class="btn btn-primary" ng-click="getSelectedItems($event)"> Get Selected Items </button> <p> </p> <p> Click below to have application update selected items in realtime <p> <input type="checkbox" ng-model="update.realtime"> Toggle Update on Change Event <p> </p> </div> </div> </div> <div> <h4>Selected Items</h4> <pre class="small">{{selectedData |json}}</pre> <h4>Source Data</h4> <pre class="small">{{myData |json}}</pre> </div> </div>
</body>
</html> <script src="js/index.js"></script>
</body>
</html>
Nested ng-repeat in AngularJS with Checkboxes - Script Codes JS Codes
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) { $scope.update = {realtime : false}; $scope.myData = [{ "number": "2013-W45", "days": [{ "templateDay": "Monday", "jobs": [{ "name": "Wakeup", }, { "name": "work 9-5", }] }, { "templateDay": "Tuesday", "jobs": [{ "name": "sleep in" }, { "name": "drop reina" }, { "name": "teach at howard" }] }] }]; $scope.getSelectedItems = function(_event) { var data = $scope.myData; var results = []; var day = null; if (!_event && !$scope.update.realtime) { return } angular.forEach(data,function(_week){ angular.forEach(_week.days,function(_day){ day = _day; angular.forEach(_day.jobs,function(_job){ if (_job.checked === true) { _job.day = day.templateDay; results.push(angular.copy(_job)); } }); }); }); $scope.selectedData = results; }
});
Developer | Aaron K Saunders |
Username | aaronksaunders |
Uploaded | September 25, 2022 |
Rating | 3 |
Size | 2,600 Kb |
Views | 54,648 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
A Pen by aaron k saunders | 2,916 Kb |
Using ui-router to control application flow | 3,448 Kb |
A Pen by aaron k saunders | 4,143 Kb |
Ionic 2 Tabs Starter | 3,059 Kb |
Promise sample for Cross-Platform mobile application class | 2,214 Kb |
Firebase Login Example | 2,682 Kb |
Demo ui-router basic state change | 2,042 Kb |
A Pen by aaron k saunders | 2,286 Kb |
Google Map Directive in Ionic | 3,479 Kb |
Angular2 Http Example | 3,851 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Vue.js Starter | Andymerskin | 1,268 Kb |
React Template | Isac | 1,241 Kb |
Reviews and Ratings Star | Zbnmstry | 1,591 Kb |
Drill-down Map | Good886 | 8,484 Kb |
Slides-07-1 POSITION | Exhtml | 1,909 Kb |
Tab Menus | Zephyr | 3,180 Kb |
Learning FlexBox | Alex_rodrigues | 2,821 Kb |
Firefox Breakout Guide | Quincysoeliman | 2,576 Kb |
Flying Bee | Pwsm50 | 3,711 Kb |
LDE old privacy page | Jasonangle | 2,339 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!