gpt4 book ai didi

javascript - 不能指定禁用并且不会输入类的名称

转载 作者:行者123 更新时间:2023-11-30 16:04:05 25 4
gpt4 key购买 nike

我有一个按钮,可以在其中使用我在 js 文件中制作的颜色设置一个类。同时它必须禁止你是否可以点击它。因此在这两个区域中返回 true 或 false。

我在这里看过:

ngclass

现在我的 disabled not 也没有,但它不会指定我在 js 文件后面制作的颜色。

HTML:

<button type="submit" ng-disabled="Disabled" ng-class="{Color: Color}" class="btn btn-effect-ripple btn-success">
{{ReadyNow()}}
</button>

js文件:

var app = angular.module('ModifyUser', [])
app.controller('RetUserInfo', function ($scope) {
$scope.ReadyNow = function () {
//Checking up on everything is empty first.
if ($scope.firstnameValue != null && $scope.lastnameValue != null && $scope.email != null && $scope.adgangskode != null) {
//says now that you can create content.
return "Ready to update now!";
$scope.Disabled = true;
$scope.Color = "btn btn-success";
}
else {
//Says that more is needed to update content.
return "Cant not update"
$scope.Disabled = false;
$scope.Color = "btn btn-warning";
}
};
//DONE
});

最佳答案

你的按钮已经添加了 btn 类,你基本上想根据条件添加 btn-warningbtn-success .

HTML

<button type="submit" ng-disabled="Disabled" ng-class="{'btn-warning: !Success, 'btn-success': Success}" class="btn btn-effect-ripple btn-success">
{{ReadyNow()}}
</button>

JS

var app = angular.module('ModifyUser', [])
app.controller('RetUserInfo', function ($scope) {
$scope.ReadyNow = function () {
//Checking up on everything is empty first.
if ($scope.firstnameValue != null && $scope.lastnameValue != null && $scope.email != null && $scope.adgangskode != null) {
//says now that you can create content.
$scope.Disabled = true;
$scope.Success = true;
return "Ready to update now!";
}
else {
//Says that more is needed to update content.
$scope.Disabled = false;
$scope.Success = false;
return "Cant not update"
}
};
//DONE
});

另请注意,您将范围变量设置为评论中提到的Jack 后返回。

关于javascript - 不能指定禁用并且不会输入类的名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37285955/

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