Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

My view (a details itemId partial that lists img tags) is rendered from my controller. The number of img varies depending on the model pointed to by itemId. I need to change the div with which contains the ing tags to # of img x img width.

To do so, I need to make sure that my javascript in the view gets ran after the partial us rendered.

How to do that?

share|improve this question
    
You can create a directive and set a watch on the "model pointed to by itemId" and in there you can change the div width, maybe after a $timeout if the dom isn't in the state that you want it during the digest cycle. –  JoseM Apr 17 '14 at 14:57

1 Answer 1

You should not do js in the view, all js must be on angularjs end controllers, directives, etc. A better approach is to use a directive else you could wait for viewContentLoaded like this:

$scope.$on('$viewContentLoaded', function () {
    //Your js
}); 
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.