Simple example on AngularJS and native JavaScript to demonstrate event life cycle