AngularJS ng-repeat do not refresh after model change with $rootScope error -


hello members of angularjs, newbie towards angular facing problems ng-repeat not refresh page after model change had manually reload model after post. functions created works flawlessly can store data / delete on database side not perform on page refresh unless manually click on f5. approach on js side.

'use strict'; var excomments = angular.module('excomments', ['nganimate']); excomments.controller('excommentsctrl', function($scope, $http){  $scope.comments; $scope.inputcomment;  $scope.getcomments = function(topic_id){     $http.get('index.php?r=explorecomment/ws_getexplorecomments&topic_id=' + topic_id, {cache:false}).success(function(data){         $scope.comments = data;         console.log($scope.comments);         console.log('comment loaded');     }); };   $scope.init = function(topic_id){     $scope.getcomments(topic_id); };  $scope.post = function(topic_id){     $scope.getcomments(topic_id);     console.log('reload comment success'); };   $scope.makepost = function(topic_id, user_id){      var formatjson = {             user_id: user_id,             topic_id: topic_id,             data: escape($scope.inputcomment),     };     var json = json.stringify(formatjson);     $http.post('index.php?r=explorecomment/ws_postcomment&json=' + json);        console.log(json);     console.log('posted');     $scope.inputcomment = "";      $scope.getcomments(topic_id);      console.log('reload comment success'); };  $scope.removepost = function(topic_id, comment_id){      $http.post('index.php?r=explorecomment/ws_deletecomment&cid=' + comment_id);     $scope.getcomments(topic_id);     console.log('delete');     console.log('reload comment success');     $scope.$apply('comments="null"'); };  }); 

i have created individual modules different page handling , inject on root app this.

var myapps = angular.module('myapps',['customdirectives','imggall','starapp', 'navbarmodel', 'carousel', 'excomments','confirmbutton','status']); 

and how html layout looks like.

<html> <!-- layouts comment display --> </html> <div ng-controller="excommentsctrl" ng-init="init(<?php echo $topic_id?>)" ng-model="comments"> <div class="explorenocommentblock" ng-if="comments.length == 0">     <h4 style="text-align: center">no comments yet... how leaving         yours above?</h4> </div>  <div class="explorecommentblock" ng-repeat="comment in comments">     <table style="width: 100%">         <tr style="width: 100%">              <td style="width: 5%" rowspan="2" valign="top"><img                 src="<?php echo urlmgmt::getuserresourceurl()?>{{comment.user_id}}/avatar/{{comment.avatar}}"                 , style='height: 64px; width: 64px; border-radius: 5px;' /></td>                <td style="width: 70%"><span class="author_name">{{comment.username}}</span>  and----so----on 

from time time when perform delete action, keep showing me error freezing entire operation changes occur on database side.

typeerror: undefined not function @ object.h [as fn] (http://localhost/viralenz/themes/viralenz/js/angular-1.2.22/angular.min.js:140:152) @ k.$digest (http://localhost/viralenz/themes/viralenz/js/angular-1.2.22/angular.min.js:109:352) @ k.$apply (http://localhost/viralenz/themes/viralenz/js/angular-1.2.22/angular.min.js:112:345) @ htmldivelement.j (http://localhost/viralenz/themes/viralenz/js/ui-bootstrap-0.11.0.min.js:8:1779) @ htmldivelement.jquery.event.dispatch (http://localhost/viralenz/assets/4483d5da/jquery.js:3058:9) @ htmldivelement.elemdata.handle.eventhandle (http://localhost/viralenz/assets/4483d5da/jquery.js:2676:46)    error: [$rootscope:inprog] http://errors.angularjs.org/1.2.22/$rootscope/inprog?p0=%24apply @ error (native) @ http://localhost/viralenz/themes/viralenz/js/angular-1.2.22/angular.min.js:6:450 @ m (http://localhost/viralenz/themes/viralenz/js/angular-1.2.22/angular.min.js:105:34) @ k.$apply (http://localhost/viralenz/themes/viralenz/js/angular-1.2.22/angular.min.js:112:276) @ k.$scope.removepost (http://localhost/viralenz/themes/viralenz/js/ng.js:395:10) @ http://localhost/viralenz/themes/viralenz/js/angular-1.2.22/angular.min.js:176:387 @ n.(anonymous function) (http://localhost/viralenz/themes/viralenz/js/angular-1.2.22/angular.min.js:53:175) @ k.$eval (http://localhost/viralenz/themes/viralenz/js/angular-1.2.22/angular.min.js:112:15) @ k.$apply (http://localhost/viralenz/themes/viralenz/js/angular-1.2.22/angular.min.js:112:293) @ htmlbuttonelement.<anonymous> (http://localhost/viralenz/themes/viralenz/js/ng.js:103:27)  

what have done wrong?

try style htmlnode modle:

display:inline-block 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -