When working with AngularJS, you may come across instances where the ng-click handler is directly connected to an HTML element like <a>
or <button>
. Take for example the snippet below (borrowed from an Angular homepage sample), where the click event for an anchor tag calling archive()
is defined.
However, doesn't this seem contradictory to the principles of the MV* framework? Shouldn't the click function be defined in a separate location instead of within the view itself? It appears that too much functionality is now tied to the anchor tag. Can someone shed some light on this?
Sample Code:
<a href="" ng-click="archive()">archive</a>