I've been trying to find out how to execute some view-specific javascript code when the model has changed. In the example below, whenever you click the "Say"-button, a new entry will be added to the model, updating the entries-list. The stylesheet limits the entries-list's height to about five entries.
What is the correct way to call something like scrollLastChatEntryElementIntoView();? I know how to scroll elements into view, but I can't seem to find any info on how and when I should do this in response to the view being updated? Where am I supposed to declare the script, and when am I supposed to call it?
<div class="chat">
<ol class="entries">
<li class="entry" ng-repeat="entry in chat.entries">
<label>{{entry.sender}}</label> {{entry.text}}
</li>
</ol>
<form class="newEntry" ng-submit="chat.newEntry.submit()">
<input class="text" ng-model="chat.newEntry.text" placeholder="Type to chat"/>
<span class="button submit" ng-click="chat.newEntry.submit()">Say</span>
</form>
</div>