Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2014
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. -------------------------
  2. Original working directive
  3. --------------------------
  4. var sidenavDirective = angular.module('sidenavDirective', [])
  5. .directive('resize', function ($window) {
  6. return {
  7. restrict: 'A',
  8.  
  9. link: function (scope, elem, attrs) {
  10.  
  11. var winHeight = $window.innerHeight;
  12.  
  13. elem.css('height', winHeight + 'px');
  14. }
  15. };
  16. });
  17.  
  18. -----------------------------
  19. New Not working modified directive
  20. -------------------------------
  21. var sidenavDirective = angular.module('sidenavDirective', [])
  22. .directive('resize', function ($window) {
  23. return {
  24. restrict: 'A',
  25.  
  26. link: function (scope, elem, attrs) {
  27. scope.$watch('window', function(newVal, oldVal){
  28. if(newVal!== oldVal){
  29. elem.css('height', winHeight + 'px');
  30. scope.$apply();
  31. }
  32. });
  33. }
  34.  
  35. };
  36. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement