我想检查两个字段的值是否相同,这些字段必须通过参数传递给验证函数,我是这样做的,问题是获取不到字段的值,出现null,因为我可以正确动态地获取值吗?
我的表单构建器,我正在使用匹配功能来检查 cell_phone 和确认字段。
this.recharge = this.formBuilder.group({
cell_phone: ['', Validators.required, Validations.match('cell_phone', 'cell_phone_confirmation')],
cell_phone_confirmation: ['', [Validators.required]],
value: ['', Validators.required],
operator_id: ['', Validators.required]
});
Run Code Online (Sandbox Code Playgroud)
在我的函数中,控制台日志为空:
static match(field1: string, field2: string){
return (group: FormGroup) => {
console.log(group.get(field1));
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个 Products 类来查找这些分页项目,但在前端我允许用户定义他想要每页显示多少个项目(10、30、50、100)问题是如果有人超过 1000, api 每页返回 1000 条记录。
如何为所有控制器和模型动态验证这一点?
我可以通过验证每个控制器上的每个请求(“限制”)来“轻松”做到这一点,但这不切实际,我该怎么做?
public function index(Request $request)
{
$perPage = $request->input('limit'); // User input
$sort = 'global_performance';
$descending = 'desc';
$products = Product::where('status', 1)
->orderBy($sort, $descending)
->paginate($perPage); //
return $products;
}
Run Code Online (Sandbox Code Playgroud) 我正在发送一个价格最多为小数点后 8 位的数组,但 trader_bbands 函数返回一个最多为小数点后 3 位的向量浮点数,我该怎么做才能返回 8 位小数?谢谢你!
我的代码:
$result = trader_bbands($arr, 21, 2.0, 2.0, TRADER_MA_TYPE_EMA);
$upper_band = end($result[0]);
$medium = end($result[1]);
$lower_band = end($result[2]);
echo '<pre>';
var_dump($lower_band, $result);
echo '</pre>';
die();
Run Code Online (Sandbox Code Playgroud) 我正在尝试在 ionic 4 中实现 popover 并且它为我显示了这个错误,我已经为 popover 创建了一个独特的组件并且我正在页面上实现,所以我点击按钮来创建它给这个的组件错误。
我正在使用延迟加载并将模块导入文件,我做错了什么?
ERROR Error: "Uncaught (in promise): Error: No component factory found for ProfileComponent. Did you add it to @NgModule.entryComponents?
Run Code Online (Sandbox Code Playgroud)
弹出模块
ERROR Error: "Uncaught (in promise): Error: No component factory found for ProfileComponent. Did you add it to @NgModule.entryComponents?
Run Code Online (Sandbox Code Playgroud)
页面模块:
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ProfileComponent } from './profile.component';
@NgModule({
declarations: [ProfileComponent],
imports: [
CommonModule,
],
entryComponents: [ProfileComponent],
})
export class ProfileModule { } …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用formControl使该选项在Ionic Select 中显示为选中状态,但是它不起作用,该值是在表单中设置的,当我键入 console.log (this.form) 时,该字段的值会出现,但是它没有出现在 select 中,是空白的。
我正在使用 ionic 4 版本。
HTML:
<!-- Analysis Mode -->
<ion-col size="12">
<ion-label class="custom-label" stacked>Modo de Análise</ion-label>
<ion-select formControlName="analysis_mode" interface="popover">
<ion-select-option value="1">Aleatório</ion-select-option>
<ion-select-option value="2">Sequencial</ion-select-option>
</ion-select>
</ion-col>
Run Code Online (Sandbox Code Playgroud)
形式:
this.form = this.formBuilder.group({
analysis_mode: new FormControl(null, Validators.required),
value: new FormControl(null, Validators.required),
});
this.form.controls['analysis_mode'].setValue(1);
Run Code Online (Sandbox Code Playgroud) 我有一个 Laravel 项目,它在 X 服务器上运行良好,并将相同的项目(相同的代码)放在另一台 Y 服务器上,令我惊讶的是经过身份验证的路由不起作用,我总是收到未经身份验证的错误,为什么会发生这种情况?
{
"message":"Unauthenticated.",
"success":false,
"status_code":500
}
Run Code Online (Sandbox Code Playgroud)
我使用的命令: - php artisan 护照:安装 - php artisan 配置:缓存 - php artisan 缓存:clear - php artisan 密钥:生成
然而我仍然收到未经身份验证的错误,令牌被前端正确传递,它是一个不记名令牌,当用户使用 createToken ('myApi') -> accessToken 方法登录时生成此令牌
public function login(AuthLoginRequest $request)
{
$user = User::with('role')->where(['email' => $request->email])->get()->first();
if(!$user){
abort(404, 'userNotFound');
}
if(!password_verify($request->password, $user->password)){
abort(401, 'invalidCredentials');
}
$token = $user->createToken('MyApiToken')->accessToken;
Access::customCreate($request->all(), $user);
$response = [
'id' => $user->id,
'name' => $user->name,
'email' => $user->email,
'profile_image' => $user->profile_image,
'token' => $token,
'old_password_changed' => $user->old_password_changed …Run Code Online (Sandbox Code Playgroud)