我有一个列表,我将其转换为 FormArray 以生成 html 中的按钮列表。我想按名称过滤汽车
汽车组件.html
<input #searchBox id="search-box" (input)="search(searchBox.value)" />
<form [formGroup]="form" *ngIf="showCars">
<input type="button" class ="btn" formArrayName="carsList" *ngFor="let car of carsList$ | async; let i = index" value="{{carsList[i].name}}" >
</form>
Run Code Online (Sandbox Code Playgroud)
CarComponent.ts
carsList$: Observable<Car[]>;
private searchTerms = new Subject<string>();
search(term: string): void {
this.searchTerms.next(term);
}
constructor(private formBuilder:FormBuilder,...)
{
this.form = this.formBuilder.group({
carsList: new FormArray([])
});
this.addButtons();
}
ngOnInit() {
this.spinner.show();
this.carsList$ = this.searchTerms.pipe(
debounceTime(300),
distinctUntilChanged(),
switchMap((term:string)=>
this.carsList ??? // Is this correct ?? What do I put here ? …Run Code Online (Sandbox Code Playgroud) 对于我可以使用ajax/jquery和存储过程快速完成的问题,我一直在摸不着头脑.我想要
1)使用Entity Framework和视图模型从数据库表中获取的值填充下拉列表.我不想使用VIEWBAG或VIEWDATA.任何帮助赞赏.
2)如何使用具有所有默认字段的视图模型生成创建视图?脚手架适用于模型,但不适用于视图模型?
我的模特
public class Employee
{
public int EmployeeID { get; set; }
public string Name { get; set; }
public string Gender { get; set; }
public string City { get; set; }
public string Level { get; set; }
public int DepartmentId { get; set; }
}
public class Grade
{
public int ID { get; set; }
public string Level { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
查看模型
public class GradeSelectListViewModel
{
public Employee Employee { …Run Code Online (Sandbox Code Playgroud) asp.net-mvc entity-framework viewmodel razor dropdownlistfor
我是C#的新手,我有一个要解决的递归问题.我希望在这个硬币更换问题中获得最少数量的硬币.我已经为它调整了一个算法,但我需要返回一个类型为Change的对象,它将包含最小可能的组合.
我试图实现一个算法,但我有所有可能的组合.
using System;
using System.Collections.Generic;
using System.Linq;
// Do not modify change
class Change
{
public long coin2 = 0;
public long bill5 = 0;
public long bill10 = 0;
}
class Solution
{
// Do not modify method signature
public static Change OptimalChange(long s)
{
Change _change = new Change();
//To implement here
return _change;
}
public static int GetCombinations(int total, int index, int[] list, List<int> cur)
{
if (total == 0)
{
foreach (var i in cur) …Run Code Online (Sandbox Code Playgroud) 我刚刚在控制器中添加了另一个 post 方法,Swagger Swashbuckle 崩溃了。如何解决这个问题?
[HttpPost]
public IActionResult CreateCars(List<Car> cars)
{
_carService.CreateCars(cars);
return NoContent();
}
System.NotSupportedException: HTTP method "POST" & path "api/Cars" overloaded by actions - IrkcnuApi.Controllers.CarsController.Create (WebApi),MyWebAPI.Controllers.CarsController.CreateCars (MyWebApi). Actions require unique method/path combination for OpenAPI 3.0. Use ConflictingActionsResolver as a workaround
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateOperations(IEnumerable`1 apiDescriptions, SchemaRepository schemaRepository)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GeneratePaths(IEnumerable`1 apiDescriptions, SchemaRepository schemaRepository)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwagger(String documentName, String host, String basePath)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
Run Code Online (Sandbox Code Playgroud) c# ×2
angular ×1
arrays ×1
asp.net-core ×1
asp.net-mvc ×1
coin-change ×1
formarray ×1
forms ×1
razor ×1
swagger ×1
swashbuckle ×1
typescript ×1
viewmodel ×1