Hello.

When you enter a message in the format "# tag message", the message is saved in localStorage

If you enter only one tag, messages associated with this tag must be dynamically counted from localStorage and displayed on the screen (without pressing the button or enter)

I do not know how to solve this problem, guys. I will forgive your help.

var app = angular.module('testApp', ["ngStorage"]); app.controller('mainCtrl', function($scope,$localStorage){ if ($localStorage.todoList || []) { $scope.todoList = $localStorage.todoList || []; $scope.todoMassive = $scope.todoList ; } $scope.todoAdd = function() { var message = $('#message').val(); var count = message.indexOf(' '); var hashtag = message.substring(0, count) if(hashtag[0] != '#') hashtag = '#' + hashtag; var text = message.substring(count, message.length); $scope.todoList.push({ hashtag:hashtag , todoText:text }); $scope.todoMessage = ""; $scope.todoHashTag = ""; $localStorage.todoList = $scope.todoList; console.log($scope.todoList); }; $localStorage.todoList = $scope.todoList; }); 

codepen.io/endoneslife/pen/yabwNA

  • the code must be directly in the question, the link may be a supplement - Grundy

1 answer 1

For this to work, you just need to add a filter in the line with ng-repeat:

 <div ng-repeat="x in todoList | filter: todoMessage"> 

Here is your example with a working CodePen filter .

  • Thank you so much) - shadelete