AngularJS Example:

by manoj

HTML

<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<script src="https://fonts.googleapis.com/icon?family=Material+Icons"></script>
<script src="https://fonts.googleapis.com/css?family=Lobster&amp;effect=brick-sign"></script>
<div class="w3-container w3-center" ng-app="VoterApp">
  <div class="w3-row-padding w3-margin-top" ng-controller="VoterController">
    <div class="w3-show-block">
      <input class="w3-input w3-border" ng-model="nameValue" maxlength="12" placeholder="What is in your name?" />
      <input class="w3-input w3-border" ng-model="mindValue" maxlength="280" placeholder="What is in your mind?" />
      <input class="w3-input w3-xlarge w3-border w3-green" type="button" value="SUBMIT" ng-click="submitIdea()" />
    </div>
    <div class="w3-container w3-section w3-yellow" ng-style="{'display':error ? 'block':'none'}">
      <span class="material-icons w3-xlarge" onclick="this.parentElement.style.display='none'">close</span>

      <h3>We need your {{error}}</h3>
    </div>
    <div class="w3-container w3-section w3-blue" style="position: absolute;z-index: 100; margin: 20%;" ng-style="{'display':message ? 'block':'none'}">
      <span class="material-icons w3-xlarge" onclick="this.parentElement.style.display='none'">close</span>

      <h3>{{message}}</h3>
    </div>
    <div ng-show="ideas.length == 0">
      Loading {{idea}}...
    </div>
    <div style="margin: 2%"></div>
    <div class="w3-third 3-third w3-animate-left" ng-repeat="item in ideas | orderObjectBy:'average'">
      <div class="w3-card-4 w3-dark-grey w3-margin w3-center">
        <header class="w3-container w3-light-grey">
          <span style="float: right;" class=" w3-card-16 w3-tag w3-xxlarge w3-round-jumbo w3-green">{{item.average}}</span>

          <h3 class="w3-label w3-xxlarge">{{item.DisplayName}}</h3>
        </header>
        <div class="w3-container">
          <img src="images/img_avatar3.png" alt="Avatar" class="w3-left...

CSS

* {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box
}

html {
  -ms-text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%
}

body {
  margin: 0
}

article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
main,
menu,
nav,
section,
summary {
  display: block
}

audio,
canvas,
video {
  display: inline-block;
  vertical-align: baseline
}

audio:not([controls]) {
  display: none;
  height: 0
}

[hidden],
template {
  display: none
}

a {
  -webkit-tap-highlight-color: transparent;
  background-color: transparent
}

a:active,
a:hover {
  outline: 0
}

abbr[title] {
  border-bottom: 1px dotted
}

b,
strong {
  font-weight: bold
}

dfn {
  font-style: italic
}

mark {
  background: #ff0;
  color: #000
}

small {
  font-size: 80%
}

sub,
sup {
  font-size: 75%;
  line-height: 0;
  position: relative;
  vertical-align: baseline
}

sup {
  top: -0.5em
}

sub {
  bottom: -0.25em
}

img {
  border: 0
}

svg:not(:root) {
  overflow: hidden
}

figure {
  margin: 1em 40px
}

hr {
  -moz-box-sizing: content-box;
  box-sizing: content-box
}

code,
kbd,
pre,
samp {
  font-family: monospace, monospace;
  font-size: 1em
}

button,
input,
optgroup,
select,
textarea {
  color: inherit;
  font: inherit;
  margin: 0
}

button {
  overflow: visible
}

button,
select {
  text-transform: none
}

button,
html input[type=button],
input[type=reset],
input[type=submit] {
  -webkit-appearance: button;
  cursor: pointer
}

button[disabled],
html input[disabled] {
  cursor: default
}

button::-moz-focus-inner,
input::-moz-focus-inner {
  border: 0;
  padding: 0
}

input[type=checkbox],
input[type=radio] {
  padding: 0
}

input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  height: auto
}

input[type=search] {
  box-sizing: content-box;
  -webkit-appearance: textfield;
  -moz-box-sizing: content-box;
  -webkit-box-sizing:...

JavaScript

var angularModule = angular.module("VoterApp", []);

angularModule.filter('orderObjectBy', function() {
  return function(input, attribute) {
    if (!angular.isObject(input)) return input;
    var array = [];
    for (var objectKey in input) {
      array.push(input[objectKey]);
    }
    array.sort(function(a, b) {
      a = parseInt(a[attribute]);
      b = parseInt(b[attribute]);
      return b - a;
    });
    return array;
  }
});
angularModule.controller("VoterController", function($scope, $timeout) {
  $scope.ideas = [];
  var ideaArray = [];
  $scope.ideas = [];
  ideaArray = [{
      "id": "0",
      "DisplayName": "Mehrdad",
      "Idea": "Why is our government not in a hurry to land our men on the moon?We’re answering: “What if they refuse to return?”",
      "comments": [{
        "value": "hahahah"
      }, {
        "value": "lol"
      }],
      "show": false,
      "average": 20,
      "VoteUp": {
        "value": 24,
        "disabled": false
      },
      "VoteDown": {
        "value": 4,
        "disabled": false
      }
    }];
  $scope.ideas = ideaArray;

  $scope.submitIdea = function() {
    if (!$scope.nameValue) {
      $timeout(caller, 4000);
      return $scope.error = " name";
    }
    if (!$scope.mindValue) {
      $timeout(caller, 4000);
      return $scope.error = " idea to show";
    }
    $scope.error = "";
    var data = {
      DisplayName: $scope.nameValue,
      Idea: $scope.mindValue
    };
    
      ideaArray.push(res);
   
    $scope.nameValue = "";
    $scope.mindValue = "";
  };

  $scope.voteClick = function(id, value) {
    if (value > 0) {
        ideaArray[id].VoteUp.value = data.VoteUp.value;
        ideaArray[id].average = data.average;
        ideaArray[id].VoteDown.disabled = true;
        ideaArray[id].VoteUp.disabled = true;
        $scope.message = "Thanks for your feed back! Your feedback saved for this person. " +
          "\nYou can only vote once for " + ideaArray[id].DisplayName;
       ...