Using AngularJS dependency inside a template -
i set max-height of div $window.innerheight. following code fails:
<div ng-style="{'max-height': $window.innerheight}" style="overflow-y: auto"> my walk-around use scope variable:
$scope.divnheight = $window.innerheight; <div ng-style="{'max-height': divheight}" style="overflow-y: auto"> is there way achieve ng-style $window binding?
thanks
you're missing 'px' in ng-style
see plunker: http://plnkr.co/edit/eqkz9wgyzm8loz6pzan0?p=preview
to answer question, no... variable wish use in html must scope variable.
if window height changing, can use watcher bind variable window height:
$scope.$watch(function(){ return $window.innerheight; // thing watch }, function(newvalue, oldvalue) { // function run when value changes console.log(newvalue); $scope.divnheight = $window.innerheight; }); update:
try adding controller, registers function fire when resize:
window.onresize = function(event) { console.log("fire resize"); $scope.divnheight = $window.innerheight; }; also, size may stay same because using max-height rather height, in case height depends on content, try using height , see if makes difference:
<div ng-style="{'height': divheight + 'px'}" style="overflow-y: auto">
Comments
Post a Comment