Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. var app = angular.module('testApp', ["ngStorage"]);
  2.  
  3. app.controller('mainCtrl', function($scope,$localStorage){
  4.  
  5. if ($localStorage.todoList || []) {
  6. $scope.todoList = $localStorage.todoList || [];
  7. $scope.todoMassive = $scope.todoList ;
  8. }
  9.  
  10.  
  11. $scope.todoAdd = function() {
  12.  
  13. var message = $('#message').val();
  14. var count = message.indexOf(' ');
  15. var hashtag = message.substring(0, count)
  16. if(hashtag[0] != '#') hashtag = '#' + hashtag;
  17. var text = message.substring(count, message.length);
  18.  
  19. $scope.todoList.push({
  20. hashtag:hashtag ,
  21. todoText:text
  22. });
  23.  
  24. $scope.todoMessage = "";
  25. $scope.todoHashTag = "";
  26.  
  27. $localStorage.todoList = $scope.todoList;
  28.  
  29. console.log($scope.todoList);
  30.  
  31. };
  32.  
  33.  
  34. $localStorage.todoList = $scope.todoList;
  35.  
  36. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement