2017-01-07 19 views
0

私はすべてうまくやっていると思いますが、まだこのエラーが発生しています。誰も私を導いてください。私は最初のMyFunctionがあり、第二はgoAndFindですが、最初のNG-変化に正常に動作しているが、onclickのボタンの両方の機能をdoesntの仕事私のjavascriptのファイルに2つの機能があります。未知のReferenceError:goAndFindはHTMLInputElement.onclickで定義されていません

が、これは私のjavascriptのファイルである

/// <reference path="angular.min.js"/> 
 
// 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" } 
 
           ]; 
 
          } 
 
         }; 
 

 
});

、これがクリックされた私のボタンのコードです

<input type="button" class="btn-success" id="findTreatment" value="Find Treatment" ng-disabled="myform.$invalid && myform.insurancefield.$invalid" onclick="goAndFind()" />

答えて

0

角度を使用しているため、onclickの代わりにng-clickを使用します。

<input type="button" class="btn-success" id="findTreatment" value="Find Treatment" ng-disabled="myform.$invalid && myform.insurancefield.$invalid" ng-click="goAndFind()" /> 

また、(例えば、setInsurance代わりのmyfunction)あなたの機能明確に名前を与えることを検討。それは後で助けになるでしょう。

関連する問題