如何根据" - "字符拆分以下字符串?
所以,如果我有这个字符串: LD-23DSP-1430
我怎么能把它拆分成单独的列,如下所示:
LD 23DSP 1430
Run Code Online (Sandbox Code Playgroud)
另外,如果我需要(没有' - '),有没有办法将每个字符分成单独的字段?我正试图找到用北约字母表替换每个字母的方法.
所以这将是.....利马三角洲二十三三角洲塞拉帕帕十四三十......在一个领域.
我知道我可以像这样得到左侧:
LEFT(@item, CHARINDEX('-', @item) - 1)
Run Code Online (Sandbox Code Playgroud) 我想一回SelectList用<optgroup>的使用SelectListGroup,但低于只有代码返回而不群选择列表的值.如何将我的选择列表按组分隔?
public SelectList MyList()
{
var group1 = new SelectListGroup() { Name = "Group 1" };
var group2 = new SelectListGroup() { Name = "Group 2" };
var items = new List<SelectListItem>();
items.Add(new SelectListItem() { Value = "1", Text = "Item 1", Group = group1 });
items.Add(new SelectListItem() { Value = "2", Text = "Item 2", Group = group2 });
return new SelectList(items, "Value", "Text");
}
Run Code Online (Sandbox Code Playgroud) 有没有一种方法可以filterMode使用Angular中的表单生成器来添加自定义属性?我正在创建一个搜索表单,但是希望能够将一个过滤器类型绑定到它,例如startsWith,contains,equal等。我希望在获取FormGroup控件对象时可以访问每个表单控件的该值。
例如:
public queryForm: FormGroup;
constructor(
private fb: FormBuilder,
) {
this.queryForm = this.fb.group({
username: [value: '', filterMode:'contains'],
email: [value: '', filterMode:'contains'],
});
}
Run Code Online (Sandbox Code Playgroud)
有没有办法在Angular中扩展FormGroup?
我在同一个项目中有一个 SPA 和 API,当我向 API 发出请求时,我不断收到以下错误。
AllowedOrigins configured and origin http://localhost:5000 is not allowed
CorsPolicyService did not allow origin: http://localhost:5000
Run Code Online (Sandbox Code Playgroud)
api的路径是:http://localhost:5000。我确保我在ClientCorsOrigins表中为客户端指定了来源,并且我还在我的Startup.cs:
services.AddCors(options =>
{
options.AddPolicy("default", policy =>
{
policy.WithOrigins("http://localhost:5000")
.AllowAnyHeader()
.AllowAnyMethod();
});
});
Run Code Online (Sandbox Code Playgroud)
我已经多次检查文档和配置,但当我在 ClientCorsOrigins 表中指定了原点时,我无法弄清楚为什么我会遇到这个问题。我正在使用谷歌浏览器。
我APP_INITIALIZER用来加载环境特定的变量。我需要在我的中使用这些变量authConfigFactory,但是工厂会APP_INITIALIZER在应用程序配置内部完成之前保持加载状态。
我正在使用这个库:https : //github.com/manfredsteyer/angular-oauth2-oidc
我想使用APP_CONFIG.authConfig.allowedUrls我的auth config工厂内部的值。我如何确保它在认证工厂之前先设置配置。
我在工厂收到此错误: Cannot read property 'authConfig' of undefined
app.module.ts:
providers: [
AppConfigService,
{
provide: APP_INITIALIZER,
useFactory: (config: AppConfigService) => () => config.load(),
multi: true,
deps: [AppConfigService]
},
{
provide: OAuthModuleConfig,
useFactory: authConfigFactory
}
]
Run Code Online (Sandbox Code Playgroud)
app.config.ts:
export let APP_CONFIG: AppConfig;
@Injectable()
export class AppConfigService {
constructor(
private injector: Injector
) {}
config = null;
public load() {
const http = this.injector.get(HttpClient);
return http
.get('../assets/config/config.json')
.pipe( …Run Code Online (Sandbox Code Playgroud)