See the link above. I want to hide the textarea when the width of the text area is over 400px. How can this be done?
-
you mean, you want to hide the text area when the browser is wider then 400px?nycynik– nycynik2012-11-28 22:23:22 +00:00Commented Nov 28, 2012 at 22:23
-
no I want to hide the textarea when it is itself > 400pxAtomix– Atomix2012-11-28 22:31:29 +00:00Commented Nov 28, 2012 at 22:31
-
so you need to listen for the resize event of the textarea? stackoverflow.com/questions/5570390/resize-event-for-textareaLiviu T.– Liviu T.2012-11-28 22:40:22 +00:00Commented Nov 28, 2012 at 22:40
Add a comment
|
1 Answer
As you're using Angular and you're dealing with view related code, you'd want to define a directive.
The code below is an example of what this directive would look like (written in CoffeeScript):
angular.module('yourAppName').directive('hideOnExceed', ->
return {
restrict: 'A',
link: (scope, element, attr) ->
element.bind 'resize', ->
if element.width() > 400
element.hide()
else
element.show()
}
)
Then simply define hideOnExceed as an attribute to the textarea tag:
<textarea ng-show="withinSize()" hideOnExceed>{{size}}</textarea>