gpt4 book ai didi

javascript - 无法在 angularJS 中填写文本输入

转载 作者:行者123 更新时间:2023-11-28 07:26:51 24 4
gpt4 key购买 nike

我有一个文本输入,我想用函数的输出填充它,但我不知道为什么它不起作用?

这是我的 html 代码:

   <input type="text" min="0" ng-model="Resqty" size="10" required >

在 angularJS 中我这样做:

      $scope.Resqty = $scope.total($scope.out);
$scope.total = function total(out) {
return data.convert($scope.qty, $scope.in, out);
};

我也尝试过直接放置函数,如下所示,但它也不起作用:

      $scope.Resqty = data.convert($scope.qty, $scope.in, $scope.out);

但是,在 html 代码中,当我输入 {{total(out)}} 时它就起作用了!我还尝试直接输入一个值来验证并且它有效!!

      $scope.Resqty = 1;

有谁知道为什么文本输入无法正确获取值?这是 Demo 的链接

提前谢谢您!

最佳答案

尝试以下操作:

$scope.formData = { Resqty: null };

$scope.formData.Resqty = $scope.total($scope.out);

查看:

<input type="text" min="0" ng-model="formData.Resqty" size="10" required >

顺便说一句,您的函数在语法上不正确:

// 2 times total, take out the second
$scope.total = function total(out) {

关于javascript - 无法在 angularJS 中填写文本输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29554927/

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