JSFiddle - React, Tailwind, and code Playground
by dshilkret
HTML
<!DOCTYPE html>
<html>
<head>
<title>Template</title>
<script src="script.js"></script>
</head>
<body>
<button onclick="$scope.displayItems()">Display Items</button>
<ul id="itemList"></ul>
</body>
</html>
JavaScript
// Define the AngularJS module
var app = angular.module('myApp', []);
// Define the controller
app.controller('myController', function($scope) {
// Define the model
$scope.items = [
{ name: 'Item 1' },
{ name: 'Item 2' },
{ name: 'Item 3' }
];
// Define the displayItems method
$scope.displayItems = function() {
for (var i = 0; i < $scope.items.length; i++) {
console.log($scope.items[i].name);
}
};
});