angular.module('app.controllers')

.controller('billCtrl', function($scope, BillService, ionicToast) {

  $scope.bill = BillService.getBill();

  $scope.addBill = function(bill, event) {

    var tempBill = angular.copy(bill);

    if(tempBill.totalAmount == undefined || tempBill.totalAmount < 0 ) {
			ionicToast.show('The amount is invalid.', 'top', false, 2500);
			event.stopPropagation();
			event.preventDefault();
		} else{
		    BillService.setBill(angular.copy(bill));
    }
	};

  $scope.calculateGrandTotal = function(bill) {
  	BillService.setBill(angular.copy(bill));
    $scope.bill = BillService.calculateGrandTotal();
  };


});

@@ -264,16 +264,47 @@
 fined %7C%7C
+ isNaN(tempBill.totalAmount) %7C%7C
  tempBil
@@ -322,11 +322,11 @@
 nt %3C
+=
  0
- 
 ) %7B%0A
@@ -665,13 +665,12 @@
 ;%0A  %7D;%0A%0A
-%0A
 %7D);%0A

Prevent zero total amount