I have the following setup in an angular.js application, basically 3 of the elements in lesson.answers are show to begin with, and the 'Move Right' button scrolls the list. (I can't seem to get it to run in the example window, but the code is simple enough to grok anyway)
(function() {
var app = angular.module('lessonEditApp');
app.controller('LessonController', function() {
this.answers = ['$15$', '$12$', '$10$', '$8$'];
this.answerPos = 0;
});
})();
<html ng-app='lessonEditApp'>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
</head>
<body ng-controller='LessonController as lesson'>
<button ng-click='lesson.answerPos = lesson.answerPos + 1'>Move Right</button>
<div ng-repeat='answer in lesson.answers | limitTo:3:lesson.answerPos'>
{{answer}}
</div>
</body>
</html>
The trouble is that those answer elements ($15$, $12$, etc) are LaTeX, and need to be marked up by another library (MathJax) after they load, so I need to know when these elements appear.
Looking at other, similar questions, answers generally propose that any extra processing steps can be done when the state changes i.e. onclick of the 'Move Right' button, but MathJax has to be called after the element has actually been rendered in the DOM in order to take effect.
Is there any way within Angular that I can trigger a function to run when elements have actually been created? Ideally it would be attached to each specific element that is shown, but a page-wide trigger would be workable.