Skip to content

Instantly share code, notes, and snippets.

@khoand0000
Created November 24, 2015 18:31
Show Gist options
  • Save khoand0000/0ef6f638c34d9c7d7e4c to your computer and use it in GitHub Desktop.
Save khoand0000/0ef6f638c34d9c7d7e4c to your computer and use it in GitHub Desktop.
Change properties of elements (ex: change height, width, color, ...) by jquery

My situation: I want to update height of side-menu (it is dynamic, its items are loaded from server). I know need to using $timeout to waiting angular build DOM done. Bellow code is right

  $scope.data = WebService.getData(function () {
      // doing something with $scope.data
      
      // must put the in here, after server return result.
      // angular using the result to build DOM again (changed everything will be destroyed)
      // using $timeout to waiting angular done
      $timeout(function() {
          $('#side-menu').css('height', ($(window).height() - 160) + 'px');
      }, 1000);
  });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment