html - Table is blank forever - loading page with ngRoute -


i using angular routers

app.config(function($routeprovider) {     $routeprovider         .when('/comment/list', {         templateurl: 'commentlist.htm',         controller: 'maincontroller'     }) }); 
<td ng-show="btnuadetails" ng-click="loadpage('commentlist', x.username);">            <a class="detailbutton" href="#/comment/list"></a>                    </td> 

and here angular function

$scope.loadpage = function(pageid, id) {      if (pageid == "commentlist") {          $scope.getserverdata($scope.generateurl(pageid, 'json', id)).then(function(result) {              $scope.servercomment = result;          });      } else {          //do      }  } 

before $http returns response html page loads , getting clean data in html table . can load page after functions returns result ? or load html file first , load again when functions returns result ?

when router changes routes, destroys $scope of current view , creates new $scope new instance of controller.

include information new view needs query parameters in new url.

change link include parameter:

<td ng-show="btnuadetails" ̶n̶g̶-̶c̶l̶i̶c̶k̶=̶"̶l̶o̶a̶d̶p̶a̶g̶e̶(̶'̶c̶o̶m̶m̶e̶n̶t̶l̶i̶s̶t̶'̶,̶ ̶x̶.̶u̶s̶e̶r̶n̶a̶m̶e̶)̶;̶"̶ >     <a class="detailbutton" href="#/comment/list?id={{x.username}}"></a> </td> 

use parameter in controller:

app.controller("maincontroller", function($scope, $route) {     this.$oninit = function() {       if ($route.current.templateurl == 'commentlist.htm') {          var pageid = 'comment';          var id = $route.current.params.id;          $scope.getserverdata($scope.generateurl(pageid, 'json', id))            .then(function(result) {              $scope.servercomment = result;          });       };     }; }); 

in above example, new instance of controller uses current params of router load necessary data.


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -