AngularJS comments form

Size
3,280 Kb
Views
32,384

How do I make an angularjs comments form?

Via http://www.interaktionsdesigner.de/2013/03/16/ein-einstieg-in-angularjs/. What is a angularjs comments form? How do you make a angularjs comments form? This script and codes were developed by Christian Fleschhut on 11 August 2022, Thursday.

AngularJS comments form Previews

AngularJS comments form - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>AngularJS comments form</title> <link rel='stylesheet prefetch' href='http://cdn.foundation5.zurb.com/foundation.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class='row'> <div class='column'> <div ng-app='app'> <div class='comments' ng-controller='CommentsCtrl'> <form> <fieldset> <legend> Your comment </legend> <div> <label> Name: <input ng-model='name' type='text'> </label> </div> <div> <label> Comment: <textarea ng-model='text'></textarea> </label> </div> <div> <input class='button' ng-click='submit()' type='submit' value='Submit'> </div> </fieldset> </form> <h3> {{comments.length}} Comments </h3> <ul> <li ng-repeat='comment in comments'> <div class='comment' ng-class='{approved: comment.approved}'> <h5> {{comment.name}}: </h5> <div> {{comment.text}} </div> <p> <small> <a ng-click='approve(comment)' ng-hide='comment.approved'> approve comment | </a> <a ng-click='drop(comment)'> delete comment </a> </small> </p> </div> </li> </ul> </div> </div> </div>
</div> <script src='https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

AngularJS comments form - Script Codes CSS Codes

.comment { opacity: 0.5;
}
.comment.approved { opacity: 1;
}

AngularJS comments form - Script Codes JS Codes

(function() { angular.module('app', []).controller('CommentsCtrl', function($scope) { $scope.comments = [ { name: 'asdf', text: 'hello world', approved: true }, { name: 'xyz', text: 'lorem ipsum', approved: false } ]; $scope.submit = function() { $scope.comments.push({ name: $scope.name, text: $scope.text, approved: false }); $scope.name = ''; return $scope.text = ''; }; $scope.approve = function(comment) { return comment.approved = true; }; return $scope.drop = function(comment) { return $scope.comments.splice($scope.comments.indexOf(comment), 1); }; });
}).call(this);
AngularJS comments form - Script Codes
AngularJS comments form - Script Codes
Home Page Home
Developer Christian Fleschhut
Username cfleschhut
Uploaded August 11, 2022
Rating 3
Size 3,280 Kb
Views 32,384
Do you need developer help for AngularJS comments form?

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!

Christian Fleschhut (cfleschhut) Script Codes
Create amazing blog posts 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!