gpt4 book ai didi

html - 未捕获的 ReferenceError : goAndFind is not defined at HTMLInputElement. onclick

转载 作者:行者123 更新时间:2023-11-28 04:35:21 24 4
gpt4 key购买 nike

我想我做的一切都很好,但我仍然收到这个错误。任何人请指导我。我的 javascript 文件中有两个函数,第一个是 myfunction,第二个是 goAndFind,但第一个在 ng-change 上运行良好,但是这两个函数在单击按钮时都不起作用:

这是我的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()" />

最佳答案

使用 ng-click 而不是 onclick,因为您使用的是 angular。

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

此外,请考虑为您的函数起一个更清晰的名称(例如,setInsurance 而不是 myfunction)。这将在以后帮助您。

关于html - 未捕获的 ReferenceError : goAndFind is not defined at HTMLInputElement. onclick,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41516564/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com