提交表单后,我想显示一个按钮,但是,验证显示为“已提交”,如果验证失败,则不false
值。
我的微调器是局部的
这导致我的微调按钮显示,尽管没有发送任何内容,因为表单已提交,但无效。
我错过了什么吗?
<button class="btn btn-lg btn-primary" [ngClass]="extraClasses" type="button" [disabled]="form.submitted" type="submit">
{{text}}
<span *ngIf="form.submitted" class="spinner-border spinner-border-sm"
role="status" aria-hidden="true"></span>
</button>
单击的提交没有详细信息-验证失败,但仍将表单标记为submitted
现在通过验证显示了我的微调器,但立即显示(submitted
对,valid
对)
答案 0 :(得分:0)
即使表单无效,您的提交按钮也会显示,这是否正常?如果不是,请执行:
<button *ngIf="sumbitedWhenValid" class="btn btn-lg btn-primary" [ngClass]="extraClasses" type="button" disabled>
{{text}}
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
</button>
编辑:
例如,您可能想在组件ts文件中创建一个属性
package application;
import javafx.animation.*;
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.*;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.shape.*;
public class Main extends Application {
static double theta = 0;
static double radius = 100;
// place the point on the orbit
static double x = radius * Math.cos(theta);
static double y = radius * Math.sin(theta);
static double angle_velocity = 0.05d;
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
BorderPane root = new BorderPane();
Scene scene = new Scene(root, 600, 600);
Group group = new Group();
group.setTranslateX(300);
group.setTranslateY(300);
Circle orbit = new Circle(radius, null);
orbit.setStroke(Color.BLACK);
Circle point = new Circle(x, y, 7, Color.BLACK);
AnimationTimer animator = new AnimationTimer() {
@Override
public void handle(long now) {
// UPDATE
theta += angle_velocity;
if (theta >= 2 * Math.PI) {
theta = 0;
}
x = radius * Math.cos(theta);
y = radius * Math.sin(theta);
// RENDER
point.setCenterX(x);
point.setCenterY(y);
}
};
animator.start();
group.getChildren().addAll(orbit, point);
root.getChildren().add(group);
primaryStage.setScene(scene);
primaryStage.show();
}
}
然后将其设置为在提交表单时该表单是否有效。例如,如果您有一个http调用,则在then()中:
IActionResult
然后将其用作微调器的条件:
View()