0

I have an Angular template with an ng-repeat. That ng-repeat loads up textareas which I would like to autosize based on their contents. In order to do that, I need to initialize a plugin on each textarea element. The problem is the textareas need to exist in order to run the script on them, and unless I set a timeout I don't know when/where to run that init call. I need to run it once the controller has run and the ng-repeat has loaded up all the textareas into the DOM. I can't seem to find an event that fires when a controller is done doing it's thing.

This seems like such a common thing. What am I missing?

1 Answer 1

1

You should put this script in a directive and put it on the ng-repeat. Here is a link to a question that has a pretty good explanation on how you might get started.

<div class="MyTextArea" ng-repeat="text int texts" my-directive>{{text}}</div>
Sign up to request clarification or add additional context in comments.

1 Comment

I ended up making a directive called "autoResize" and putting it on the textarea itself. Then inside the directive, I run the plugin on the passed in element inside of scope.$watch().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.