{"id":107,"date":"2016-04-04T02:39:32","date_gmt":"2016-04-04T02:39:32","guid":{"rendered":"http:\/\/windows.emacslisp.com\/?p=107"},"modified":"2016-04-04T04:12:08","modified_gmt":"2016-04-04T04:12:08","slug":"some-trick-in-ng-repeat-update-model-in-ionic","status":"publish","type":"post","link":"http:\/\/windows.emacslisp.com\/index.php\/2016\/04\/04\/some-trick-in-ng-repeat-update-model-in-ionic\/","title":{"rendered":"some tricky in ng-repeat update model in ionic"},"content":{"rendered":"<p>ng-repeat is to loop thought object list and auto generated html.<\/p>\n<p>for example<br \/>\nin controller, we declare<br \/>\n$scope.workspaces.<\/p>\n<p>Now $scope.workspaces = getDataFromDatabase();<\/p>\n<pre lang=\"html4strict\" line=\"1\"> \r\n<li class=\"workspace-object\" ng-repeat=\"w in workspaces | filter:searchQuery\" ng-click=\"selectWorkspace(w)\">\r\n    <a href=\"\" class=\"workspace-link\">{{w.name | titleCase }}<\/a>\r\n<\/li>\r\n<\/pre>\n<p>It will not updated.<\/p>\n<p><strong>Make following change it will work.<\/strong><\/p>\n<pre lang=\"javascript\" line=\"1\">\r\n$scope.work={}; \/\/very important, declare object first.\r\n$scope.work.workspaces = getDataFromDatabase(); \/\/workspaces object should under work object.\r\n<\/pre>\n<p>change ng-repeat to be ng-repeat=&#8221;w in work.workspaces | filter:searchQuery&#8221;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ng-repeat is to loop thought object list and auto generated html. for example in controller, we declare $scope.workspaces. Now $scope.workspaces = getDataFromDatabase(); {{w.name | titleCase }} It will not updated. Make following change it will work. $scope.work={}; \/\/very important, declare &hellip; <a href=\"http:\/\/windows.emacslisp.com\/index.php\/2016\/04\/04\/some-trick-in-ng-repeat-update-model-in-ionic\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"_links":{"self":[{"href":"http:\/\/windows.emacslisp.com\/index.php\/wp-json\/wp\/v2\/posts\/107"}],"collection":[{"href":"http:\/\/windows.emacslisp.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/windows.emacslisp.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/windows.emacslisp.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/windows.emacslisp.com\/index.php\/wp-json\/wp\/v2\/comments?post=107"}],"version-history":[{"count":4,"href":"http:\/\/windows.emacslisp.com\/index.php\/wp-json\/wp\/v2\/posts\/107\/revisions"}],"predecessor-version":[{"id":111,"href":"http:\/\/windows.emacslisp.com\/index.php\/wp-json\/wp\/v2\/posts\/107\/revisions\/111"}],"wp:attachment":[{"href":"http:\/\/windows.emacslisp.com\/index.php\/wp-json\/wp\/v2\/media?parent=107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/windows.emacslisp.com\/index.php\/wp-json\/wp\/v2\/categories?post=107"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/windows.emacslisp.com\/index.php\/wp-json\/wp\/v2\/tags?post=107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}