小编Kév*_*nto的帖子

idangerous swiper,编号中的数字

可以在每个"swiper-pagination-switch"范围内显示滑块的数量?(如:1,2,3,......)?

默认情况下,插件会创建HTML的一部分,如下所示:

<div class="pagination">
    <span class="swiper-pagination-switch swiper-visible-switch swiper-active-switch"></span>
    <span class="swiper-pagination-switch"></span>
    <span class="swiper-pagination-switch"></span></div>
</div>
Run Code Online (Sandbox Code Playgroud)

我想在每个跨度中插入与之相关的幻灯片数量,如下所示:

<div class="pagination">
    <span class="swiper-pagination-switch swiper-visible-switch swiper-active-switch">1</span>
    <span class="swiper-pagination-switch">2</span>
    <span class="swiper-pagination-switch">3</span></div>
</div>
Run Code Online (Sandbox Code Playgroud)

我怎么能这样做?

谢谢.

javascript plugins swiper

2
推荐指数
1
解决办法
7928
查看次数

在Angular 2中异步验证表单字段(在HTTP请求之后)

我们的想法是让用户POST表单.并触发API返回的错误,如果用户已经注册,则将电子邮件字段设置为错误.

我使用FormBuilder的反应形式,我尝试在订阅错误捕获器中调用验证器:

构造函数:

this.email = fb.control('', [Validators.required, Validators.pattern(/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/), SignupComponent.alreadyExist()]);
this.username = fb.control('', [Validators.required, Validators.pattern(/^([A-ZÀ-ÿa-z0-9]{2,})+(?:[ _-][A-ZÀ-ÿa-z0-9]+)*$/)]);

this.userRegisterForm = fb.group({
    email: this.email,
    username: this.username
});
Run Code Online (Sandbox Code Playgroud)

自定义alreadyExist()验证器:

static alreadyExist(alreadyExist: boolean = false): any {

    return (control: FormControl): { [s: string]: boolean } => {

        if(alreadyExist) {
            return { emailAlreadyExist: true }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

}

onSubmit():

this.user.create(newUser)
    .subscribe(
        data => {
            this.router.navigate(['signin']);
        },
        error => {
            if(error.status === 401) {

                // CALL THE VALIDATOR HERE TO SET : FALSE
                SignupComponent.alreadyExist(true);
            }

            this.loading = …
Run Code Online (Sandbox Code Playgroud)

customvalidator formbuilder typescript angular

2
推荐指数
1
解决办法
2864
查看次数