我有这样的 HTML 代码。
<div class="col-md-10">
<ng-select [items]="tests" (data)="updateSelected($event, 'test')">
</ng-select>
</div>
Run Code Online (Sandbox Code Playgroud)
我的打字稿代码如下
@Input() tests: Option[] = []; I have tests coming as input from previous component
@ViewChildren(SelectComponent)
private selectComponents: QueryList<SelectComponent>;
ngAfterViewInit() {
this.selectComponents;
}
Run Code Online (Sandbox Code Playgroud)
我如何在 selectComponents 中将某个值设置为默认值,或者是否有其他方法可以使用 ng-select 将某个值设置为默认值。
我创建了一个基于 node.js express 和 react 的小项目。
我的项目结构很简单

我运行 node 作为服务器和所有反应代码 winthinclient文件夹。
我的节点package.json如下所示:
"scripts": {
"start": "concurrently \"npm run server\" \"npm run client\"",
"server": "node ./bin/www",
"client": "node start-client.js",
"lint:client": "(cd ./client && npm run lint)",
"lint:app": "eslint . --ext .js,.jsx --ignore-pattern 'client/*'",
"lint": "npm run lint:client && npm run lint:app",
"dev:client": "(cd ./client && npm start)",
"dev:app": "nodemon ./bin/www",
"build": "(cd ./client && npm run build)",
"test:client": "(cd ./client && CI=true npm test)",
"test:app": "jest --forceExit", …Run Code Online (Sandbox Code Playgroud) 有人知道如何重置我的输入类型=“文件”吗?我一直在使用$this->reset()来清除 input 的属性type="file"。
$this->reset(['type', 'name', 'institution', 'year', 'certification']);
Run Code Online (Sandbox Code Playgroud)

基于 angular.io 英雄教程教程中的搜索,我使用 observable 创建了一个简单的动物搜索。一切正常,但是我现在想清除搜索中的值,并在选择结果时清除结果列表。


我创建了一个方法来清除单击链接时的输入值,期望 observable 会更新和清除,不幸的是这并没有发生,并且下拉列表仍然存在。我试过重新分配 observable,这是可行的,但随后 observable 被取消订阅,这是我不想做的事情。
我确定这是我还没有完全理解如何使用 observables 的一个例子,所以希望你们能帮助我。
谢谢,这是我的代码。
import { Component, OnInit } from '@angular/core';
import {Observable, Subject} from 'rxjs'
import {
debounceTime, distinctUntilChanged, switchMap
} from 'rxjs/operators';
import { AnimalService } from '../services/animal.service';
import { Animal } from '../models/animal';
@Component({
selector: 'app-animal-search',
templateUrl: './animal-search.component.html',
styleUrls: ['./animal-search.component.css']
})
export class AnimalSearchComponent implements OnInit {
animals$: Observable<Animal[]>;
private searchTerms = new Subject<string>();
private searchTerm: string;
constructor(private animalService: AnimalService) { }
search(term: string):void {
this.searchTerms.next(term); …Run Code Online (Sandbox Code Playgroud) 我有一个非常简单的查询,可从数据库获取记录:
\DB::table("table")->get();
Run Code Online (Sandbox Code Playgroud)
当我尝试从数据库中获取超过±145000条记录时,我得到了:
500 server error。
代码如下:
\DB::table("table")->take(14500)->get();
Run Code Online (Sandbox Code Playgroud)
虽然有效。当我尝试获取超过15k的值时,我立即得到错误,而没有任何负载或其他信息。我也无法从日志中获取更多信息。奇怪的是,当我将代码写入修补程序时,我可以获得所有记录。(与雄辩的作品一样)

代码看起来没问题,但是却出现了这个错误。它说 TypeError: Cannot read property 'length' of null in React Project. 我已经发布了下面的代码。我正在使用 React Js 来构建它。请帮助。
import React, {useEffect} from 'react'
import { Link } from 'react-router-dom'
import { useDispatch, useSelector } from 'react-redux'
import { Row, Col, ListGroup, Image, Form, Button, Card } from 'react-bootstrap'
import Message from '../components/Message'
import { addToCart } from '../actions/cartActions'
function CartScreen({ match, location, history }) {
const productId = match.params.id
const qty = location.search ? Number(location.search.split('=')[1]) : 1
const dispatch = useDispatch()
const cart …Run Code Online (Sandbox Code Playgroud) 我有一条路线:
Route::get('/setlocale/{locale}', function($locale) {
App::setLocale($locale);
return back();
})->name('setlocale');
Run Code Online (Sandbox Code Playgroud)
当我转到:example.com/setlocale/ro我返回页面。但是语言没有改变。为什么?我总会说语言en。我通过以下方式检查语言:
app()->getLocale();
Run Code Online (Sandbox Code Playgroud)
但是我需要全局设置语言才能应用。
在每个 Laravel 模型中,我想像下面这样声明可填充。
protected $fillable = [
'object_name','attributes','item','cost','status','category',
'object_id','status','customer_id','provider_id'
];
Run Code Online (Sandbox Code Playgroud)
之后,我可以在数据库中插入值。有什么方法可以使每个新创建的表的所有列都可填充,还是我每次都需要更改它?
laravel ×3
angular ×2
php ×2
reactjs ×2
eloquent ×1
javascript ×1
laravel-5 ×1
laravel-5.1 ×1
laravel-8 ×1
localization ×1
node.js ×1
observable ×1
postgresql ×1
rxjs ×1
typeerror ×1
typescript ×1