正如我在标题中提到的那样,我正在尝试验证用户输入的手机号码是否是印度号码。
为此,我从印度手机号码的正则表达式中引用了一种模式
但就我而言,它总是返回false。
我想验证以下内容。
app.component.html
<form class="example-form" [formGroup]="userAddressValidations">
<mat-form-field appearance="outline" class="col-sm-6">
<mat-label>10-digit Mobile Number</mat-label>
<input matInput formControlName="mobileNumber" maxlength="10" (keypress)=_keyPress($event)>
<mat-error *ngIf="userAddressValidations.get('mobileNumber').hasError('required')">
Please fill out this field.
</mat-error>
<mat-error *ngIf="userAddressValidations.get('mobileNumber').hasError('pattern')">
It is not a valid mobile number.
</mat-error>
</mat-form-field>
</form>
Run Code Online (Sandbox Code Playgroud)
app.component.ts
export class InputErrorStateMatcherExample {
userAddressValidations: FormGroup;
constructor(private formBuilder: FormBuilder) { }
ngOnInit() {
this.userAddressValidations = this.formBuilder.group({
mobileNumber: ['', [Validators.required, Validators.pattern('^[6-9]\d{9}$')]]
});
}
_keyPress(event: any) {
const pattern = /[0-9]/;
let inputChar = String.fromCharCode(event.charCode);
if (!pattern.test(inputChar)) { …Run Code Online (Sandbox Code Playgroud) 我是角度6的新手,这里有一个带有mat-sidenav的mat-toolbar。一切工作正常,但我想在侧面nav菜单中为活动项设置颜色。
目前我有黑色背景,我想在mat-nav-list中选择项目时设置颜色,并且尝试在每个也不起作用的项目之间设置mat-divider。
app.component.html
<mat-sidenav-container class="sidenav-container">
<mat-sidenav #drawer class="sidenav" fixedInViewport="true" [attr.role]="(isHandset$ | async) ? 'dialog' : 'navigation'"
[mode]="(isHandset$ | async) ? 'over' : 'side'" [opened]="!(isHandset$ | async)" style="background:black"> //current background is black
<mat-toolbar class="menuBar">Menus</mat-toolbar>
<mat-nav-list>
<a class="menuTextColor" mat-list-item href="#">Link 1</a> // want to change the color of the selected item.
<a class="menuTextColor" mat-list-item href="#">Link 2</a> // want to set divider between each item
<a class="menuTextColor" mat-list-item href="#">Link 3</a>
</mat-nav-list>
</mat-sidenav>
<mat-sidenav-content>
<mat-toolbar class="toolbar">
<button class="menuTextColor" type="button" aria-label="Toggle sidenav" mat-icon-button (click)="drawer.toggle()" *ngIf="isHandset$ …Run Code Online (Sandbox Code Playgroud) 我正在使用角度4应用程序,在此我尝试使用方法的参数值添加1.
例如:如果方法接收1作为参数值,我想在方法中添加参数值+ 1但是它返回11而不是2.
addCount(mCount){
mCount += 1;
console.log(mCount);
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮我解决这个问题
我试图在 mat-icon 按钮而不是其他图标中设置数字。但就我而言,当我设置其他一些图标时,它正在工作,但当我设置数字时,它显示一个空白按钮。
我尝试解决但找不到问题所在。
应用程序组件.html
<div class="col-sm-9">
<div class="container">
<div class="row">
<div class="col-sm-12">
<div class="row">
<div class="col-sm-4">
<button mat-mini-fab><mat-icon >1</mat-icon></button>
</div>
<div class="col-sm-4">
<button mat-mini-fab><mat-icon >2</mat-icon></button>
</div>
<div class="col-sm-4">
<button mat-mini-fab><mat-icon >3</mat-icon></button>
</div>
<div class="col-sm-4">
<button mat-mini-fab><mat-icon >4</mat-icon></button>
</div>
</div>
</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
谁能帮我解决它。
我是 SQL Server 的新手,我正在尝试将日期插入到具有 DATETIMEas 数据类型。
当我将日期时间从 API 传递给存储过程时,它会插入我传递的值。但是如果我传递一个空字符串" ",它会插入一个默认值1900-01-01 00:00:00.000. 但我想插入,NULL如果数据是 " ".
我用谷歌搜索了很多,但找不到解决方案。
@DATEVAL1 DATETIME = '',
@DATEVAL1 DATETIME = ''
INSERT INTO TABLE (mDate1, mDate2)
VALUES (@DATEVAL1, @DATEVAL2);
Run Code Online (Sandbox Code Playgroud)
这是我的存储过程中的代码。
我是 Angular 5 的新手,在这里我面临着组件路由的问题。
我想要做的是,当用户首先打开应用程序时,它应该显示一个登录屏幕(登录屏幕具有浏览器窗口的全高和全宽)。一旦用户成功验证,用户就会进入Home 组件。
这里 Home 组件有 Toolbar 和 Side menu bar ,如果用户从侧边菜单栏中选择了任何一个,我想在 home 组件的内容区域中显示相关(组件)数据。
截至目前一切正常,我的意思是当用户打开应用程序登录屏幕时首先显示并成功验证主页显示给用户。
当用户从侧边菜单栏中选择任何菜单时会出现问题,该组件未显示在 Home 组件的内容区域中,它作为单独的组件打开并全屏显示。
home.component.ts
<mat-sidenav-container class="sidenav-container">
<mat-sidenav #drawer class="sidenav" fixedInViewport="true" [attr.role]="(isHandset$ | async) ? 'dialog' : 'navigation'"
[mode]="(isHandset$ | async) ? 'over' : 'side'" [opened]="!(isHandset$ | async)" style="background:black">
<mat-toolbar class="menuBar">Menus</mat-toolbar>
<mat-nav-list>
<a class="menuTextColor" mat-list-item routerLink="/settings">Link 1</a>
</mat-nav-list>
</mat-sidenav>
<mat-sidenav-content>
<mat-toolbar class="toolbar">
<button class="menuTextColor" type="button" aria-label="Toggle sidenav" mat-icon-button (click)="drawer.toggle()"
*ngIf="isHandset$ | async">
<mat-icon aria-label="Side nav toggle icon">menu</mat-icon>
</button>
<span …Run Code Online (Sandbox Code Playgroud) 我是 c# 新手,我想在 Web API 中将模型类对象转换为 DataTable。
模型类
public class Employee_Master_Model
{
public string UserType { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string MiddleName { get; set; }
public string Mobile { get; set; }
public string Phone { get; set; }
public string Email { get; set; }
public bool IsActive { get; set; }
public int EmployeeId { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
控制器:
public async Task<IActionResult> …Run Code Online (Sandbox Code Playgroud) typescript ×5
angular ×3
.net ×1
angular5 ×1
angular6 ×1
asp.net-core ×1
c# ×1
sql ×1
sql-server ×1