Guest User

Untitled

a guest
Feb 9th, 2015
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. app.controller("radioController", function ($scope) {
  2.  
  3.     $scope.newItem = "";
  4.     $scope.currentItem = "";
  5.  
  6.     $scope.delete = function (index) {
  7.         $scope.model.splice(index, 1);
  8.         for (var i = 0; i < $scope.model.length; i++) {
  9.             $scope.model[i].edit = false;
  10.         }
  11.     };
  12.     $scope.edit = function (index) {
  13.         for (var i = 0; i < $scope.model.length; i++) {
  14.             $scope.model[i].edit = false;
  15.         }
  16.         $scope.model[index].edit = true;
  17.         $scope.currentItem = $scope.model[index].value;
  18.     };
  19.     $scope.cancel = function (index) {
  20.         for (var i = 0; i < $scope.model.length; i++) {
  21.             $scope.model[i].edit = false;
  22.         }
  23.         $scope.model[index].value = $scope.currentItem;
  24.     };
  25.     $scope.save = function (item) {
  26.         if (!item.value)
  27.             return;
  28.         item.edit = false;
  29.     };
  30.     $scope.add = function () {
  31.         if (!$scope.newItem)
  32.             return;
  33.         var item = {
  34.             "value": $scope.newItem,
  35.             "edit" : false,
  36.         };
  37.         $scope.model.push(item);
  38.         $scope.newItem = "";
  39.     };
  40.     $scope.toTop = function (index) {
  41.         var tmp = $scope.model[index];
  42.         $scope.model[index] = $scope.model[index - 1];
  43.         $scope.model[index - 1] = tmp;
  44.     };
  45.     $scope.toBottom = function (index) {
  46.         var tmp = $scope.model[index];
  47.         $scope.model[index] = $scope.model[index + 1];
  48.         $scope.model[index + 1] = tmp;
  49.     };
  50.  
  51.  
  52.  
  53.     $scope.model = [
  54.         {
  55.             "value": "Facet",
  56.             "edit": false,
  57.         },
  58.         {
  59.             "value": "Kobieta",
  60.             "edit": false,
  61.         },
  62.         {
  63.             "value": "Dziecko",
  64.             "edit": false,
  65.         },
  66.     ];
  67.  
  68.  
  69. });
Advertisement
Add Comment
Please, Sign In to add comment