title: Uncaught ReferenceError: goAndFind is not defined at HTMLInputElement.onclick
body: <p>i think i am doing everything fine but still i am getting this error. anybody please guide me through. i have two functions in my javascript file first is myfunction and second is goAndFind  but first is working fine on ng-change but both function doesnt work onclick on a button :</p>
  
  <p>this is my javascript file</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>/// &lt;reference path="angular.min.js"/&gt;
  // Initialize Firebase
  var config = {
      apiKey: "AIzaSyDTTDn-oR0XadcSwllwUkukrw86eH2Ch0g",
      authDomain: "mvprecovery.firebaseapp.com",
      databaseURL: "https://mvprecovery.firebaseio.com",
      storageBucket: "mvprecovery.appspot.com",
      messagingSenderId: "119468568560"
  };
  firebase.initializeApp(config);
  var myapp = angular
                      .module("mymodule", ['firebase'])
                      .controller("mycontroller", function ($scope , $firebaseObject) {
                          
                          $scope.selectState;
                          $scope.findTreatment = findTreatment;
                          $scope.selectState = selectState;
                          $scope.selectedInsurance = selectedInsurance;
  
                          $scope.goAndFind = function writeUserData() {
                                          firebase.database().ref('tempdata/' + userId).set({
                                              insurance: $scope.selectedInsurance,
                                              state: $scope.selectState,
                                              treatment: $scope.findTreatment
                              });
                          };
  
                          $scope.myfunction = function () {
                              if ($scope.selectState == "Pennsylvania") {
                                  $scope.insurance = [
                                                      { name: "Ford Mustang" },
                                                      { name: "Fiat 500" },
                                                      { name: "Volvo XC90" }
                                  ];
                              } else if ($scope.selectState == "new-jersey") {
                                  $scope.insurance = [
                                                 { name: "lahore" },
                                                 { name: "kamalia" },
                                                 { name: "bingokml" }
                                  ];
                              }  
                          };
  
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p>and this is my button code that is clicked </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code> &lt;input type="button" class="btn-success" id="findTreatment" value="Find Treatment" ng-disabled="myform.$invalid &amp;&amp; myform.insurancefield.$invalid" onclick="goAndFind()" /&gt;</code></pre>
  </div>
  </div>
  </p>