在 Angular 上,我尝试使用以下正则表达式验证电子邮件 -
^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$
Run Code Online (Sandbox Code Playgroud)
如下图——
createGroupForm() {
this.childGroupForm = new FormGroup({
'groupName': new FormControl(null, Validators.compose([
Validators.required
])),
'groupEmail': new FormControl(null, Validators.compose([
Validators.pattern('^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$')
]))
});
}
Run Code Online (Sandbox Code Playgroud)
但看起来它不起作用。它总是显示“电子邮件无效。”,即使它是有效的。
我已经检查了所有关于通过 Header 设置 cookie 的帖子,我总是看到人们推荐这样写:
withCredentials: 真
我正在尝试这样做,但遇到了同样的错误。
$scope.myAppsLoginResponse = JSON.stringify(response.data, null, 3);
var dataC = JSON.parse($scope.myAppsLoginResponse);
$cookies.cookie = 'Somethin here as cookie';
var userId = dataC.user_id;
var thePath = '/thePath';
var theURL = 'https://theUrl';
var cookieRes = $cookies.cookie;
document.cookieMyApp = cookieRes;
var headers2 = {};
headers2 ['Accept-Language'] = 'es-ES';
headers2 ['Cookie'] = document.cookieMyApp;
headers2 ['Authorization'] = 'Basic Z2743ASasdh23Q=';
var param = {}
param ['userId'] = userId;
var req2 = {
method: 'GET',
url: theURL + thePath ,
headers: headers2, …Run Code Online (Sandbox Code Playgroud)