调用此代码片段LINQ(语言集成查询)是否正确?
var lstMyStrings = new List<string>();
lstMyStrings.Where(aX => string.IsNullOrEmpty(aX))
.Skip(3)
.ToList();
Run Code Online (Sandbox Code Playgroud)
我很困惑因为这段代码System.Linq是强制性的.
但是,当我看到问题和答案是这样的:.NET LINQ查询语法与方法链
,然后他们明确谈论方法链而不是LINQ.
我有以下项目层次结构:
-MyDotNetProject
...
L wwwroot
L angular
L src
L angulardev.html
L index.html
Run Code Online (Sandbox Code Playgroud)
现在我想在启动应用程序时使用angulardev.html作为起点.
我试过在Startup.cs/Configure中跟进,但它不起作用.
DefaultFilesOptions defaultFilesOptions = new DefaultFilesOptions();
defaultFilesOptions.DefaultFileNames.Clear();
defaultFilesOptions.DefaultFileNames.Add("angulardev.html");
app.UseDefaultFiles(defaultFilesOptions);
var path = Path.Combine(env.ContentRootPath, "angular/src");
var provider = new PhysicalFileProvider(path);
var options = new StaticFileOptions();
options.RequestPath = "";
options.FileProvider = provider;
app.UseStaticFiles(options);
Run Code Online (Sandbox Code Playgroud) 我想知道两者之间是否存在差异
ng build --prod
Run Code Online (Sandbox Code Playgroud)
和
ng build --prod --aot
Run Code Online (Sandbox Code Playgroud)
文件大小对我来说保持不变.是--aot,如果你指定自动选择--prod?
我尝试在 Angular 11 中实现验证器,但出现编译错误:
Type '(controlArray: FormArray) => ValidationErrors | null' is not assignable to type 'ValidatorFn'.任何想法如何修复此错误?
验证器类:
import { FormArray, ValidationErrors } from "@angular/forms";
export class BookValidators {
static atLeastOneAuthor(controlArray: FormArray): ValidationErrors | null {
if(controlArray.controls.some(el => el.value)){
return null;
}else{
return{
atLeastOneAuthor: {
valid: false
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
调用类
constructor(private fb: FormBuilder){}
private buildAuthorsArray(values: string[]): FormArray{
// BookValidators.atLeastOneAuthor is now underlined with the error.
return this.fb.array(values, BookValidators.atLeastOneAuthor);
}
Run Code Online (Sandbox Code Playgroud)