??? form ng-submit

can't reset the {{needed}} & will call 'requestFunding()' no matter what. can't trigger 'ng-change'

by fangunxs

HTML

<form ng-submit='requestFunding()' ng-controller='StartUpController'>
    Starting: <input ng-change='computeNeeded()' ng-model='funding.startingEstimate'>
    Recommendation: {{needed}}
    <button>Fund my startup!</button>
    <button ng-click="reset()">Reset</button>
</form>

JavaScript

function StartUpController($scope) {
    $scope.requestFunding = function() {
        window.alert("Sorry, please get more customers first.");
    };
    
    $scope.computeNeeded = function() {
        $scope.needed = $scope.funding.startingEstimate * 10;
    };
    
    $scope.reset = function() {
        $scope.funding.startingEstimate = 0;
    };
}