Reworked to use AngularJS for data binding.