Nested ng-repeat in AngularJS with Checkboxes

Size
2,600 Kb
Views
54,648

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 Previews

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>&nbsp</p> <button class="btn btn-primary" ng-click="getSelectedItems($event)"> Get Selected Items </button> <p>&nbsp</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>&nbsp</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; }
});
Nested ng-repeat in AngularJS with Checkboxes - Script Codes
Nested ng-repeat in AngularJS with Checkboxes - Script Codes
Home Page Home
Developer Aaron K Saunders
Username aaronksaunders
Uploaded September 25, 2022
Rating 3
Size 2,600 Kb
Views 54,648
Do you need developer help for Nested ng-repeat in AngularJS with Checkboxes?

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!

Aaron K Saunders (aaronksaunders) Script Codes
Create amazing love letters with AI!

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!