任何人都可以向我澄清我应该如何使用.forRoot()调用构建多个嵌套的功能模块层次结构?
例如,如果我有这样的模块怎么办:
- MainModule
- SharedModule
- FeatureModuleA
- FeatureModuleA1
- FeatureModuleA2
- FeatureModuleB
Run Code Online (Sandbox Code Playgroud)
所有要素模块都具有.forRoot()静态函数.
我应该如何定义FeatureModuleA以某种方式"转移".forRoot()函数?
@NgModule({
imports: [
//- I can use .forRoot() calls here but this module not the root module
//- I don't need to import sub-modules here, FeatureA only a wrapper
//FeatureModuleA1.forRoot(), //WRONG!
//FeatureModuleA2.forRoot(), //WRONG!
],
exports: [
//I cannot use .forRoot() calls here
FeatureModuleA1,
FeatureModuleA2
]
})
class FeatureModuleA {
static forRoot(): ModuleWithProviders {
return {
//At this point I can set any …Run Code Online (Sandbox Code Playgroud) 我已经安装了带有.NET Core和Docker的Visual Studio 2017社区RC(预览版),所以我可以在我的项目上尝试"添加docker support".
不幸的是,我无法让事情协同工作(win8.1 + docker工具箱+ hyperv引擎+ docker工具似乎不能很好地协同工作)所以我决定从我的项目中删除docker支持.
没有任何菜单项可以删除docker支持,所以我只是从解决方案中删除了所有与docker相关的文件.
目前,当我尝试构建/重建/清理/ ...时出现错误:
错误MSB4018"CleanWorkspace"任务意外失败.System.IO.FileNotFoundException:找不到文件'D:\ dev\AspNetCore\docker-compose.yml'.
错误MSB4018"PrepareForCompile"任务意外失败.System.IO.FileNotFoundException:找不到文件'D:\ dev\AspNetCore\docker-compose.yml'.
我试图删除bin,obj,.vs文件夹没有运气.
我刚开始学习nodejs-postgres并找到了pg-promise包裹.我阅读了文档和示例,但我不明白我应该在哪里放置初始化代码?我使用Express,我有很多路线.
我必须将整个初始化(包括pg-monitorinit)放到我想要查询db的每个文件中,或者我只需要initalize/configure在server.js中包含它们?
如果我只在server.js中初始化它们应该包含哪些我需要db查询的文件呢?
换一种说法.我不清楚pg-promise和pg-monitor configuration/initalization是全局还是本地行动?
我还不清楚是否需要为每个查询创建一个db变量并结束pgp?
var db = pgp(connection);
db.query(...).then(...).catch(...).finally(**pgp.end**);
Run Code Online (Sandbox Code Playgroud) 我下载并安装了最新的.NET Core:
dotnet --version
1.0.0-preview5-004478
Run Code Online (Sandbox Code Playgroud)
我还更新了我的AspNetCore项目的包引用:
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.1</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.TagHelpers" Version="1.1.0" />
<PackageReference Include="Microsoft.NETCore.App" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Tools" Version="1.1.0-preview4-final" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.0-preview4-final" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.1.0-preview4-final" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.1.0" …Run Code Online (Sandbox Code Playgroud) 我试图找出为ngModel实现自定义验证器逻辑的最简单方法.我有一个预定义的模型(接口),它存储当前数据,所以我不想处理新的FormGroup/FormControl(模型驱动)方法.
如果我已经拥有了我需要的所有数据,为什么要使用FormControls构建完全相同的模式?
这是我的代码(https://plnkr.co/edit/fPEdbMihRSVqQ5LZYBHO):
import { Component, Input } from '@angular/core';
export interface MyWidgetModel {
title:string;
description:string;
}
@Component({
selector: 'my-widget',
template: `
<h4 *ngIf="!editing">{{data.title}}</h4>
<input *ngIf="editing" type="text" name="title" [(ngModel)]="data.title">
<p *ngIf="!editing">{{data.description}}</p>
<textarea *ngIf="editing" name="description" [(ngModel)]="data.description" (ngModelChange)="customValidator($event)"></textarea>
<button (click)="clickEditing()">{{editing ? 'save' : 'edit'}}</button>
`
styles: [
':host, :host > * { display: block; margin: 5px; }',
':host { margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid #eee; }',
'.ng-invalid { background-color: #FEE; }'
]
})
export class MyWidgetComponent {
@Input() …Run Code Online (Sandbox Code Playgroud) 为什么这段代码不能按预期工作?在Test(&$ array)函数内部,我将ref参数设置为全局$ array1,但这不起作用.
$array1 = array();
$array2 = array();
function Test(&$array)
{
global $array1;
$array = &$array1;
$array['inside'] = 'inside';
}
Run Code Online (Sandbox Code Playgroud)
//由功能设定:
Test($array2);
$array2['test1'] = 'test1';
var_dump($array1); //array('inside' => 'inside') ** WHERE IS THE 'test1' key? **
var_dump($array2); //array('test1' => 'test1') ** WHERE IS THE 'inside' key? **
Run Code Online (Sandbox Code Playgroud)
//没有功能的设置:
$array2 = &$array1;
$array2['test2'] = 'test2';
var_dump($array1); //array('inside' => 'inside', 'test2' => 'test2') ** FINE **
var_dump($array2); //array('inside' => 'inside', 'test2' => 'test2') ** FINE **
Run Code Online (Sandbox Code Playgroud)
编辑:
很明显,如果我将$ array更改为指向$ array1,那么$ array1将在函数 …
我尝试创建一个比较原始值和更新后的值的函数,并将原始值设置为更新后的值(如果不同)。该函数的作用更多,因此我简化了对主题的讨论:
public void Match<T>(Expression<Func<object>> original, Expression<Func<object>> updated)
{
var mex = original.Body as MemberExpression;
var funcOriginal = original.Compile();
var funcUpdated = updated.Compile();
var valueOriginal = funcOriginal();
var valueUpdated = funcUpdated();
if (valueOriginal != valueUpdated)
{
var info = mex.Member as PropertyInfo;
var target = ???; //How to get the original.TestProperty here?
info.SetValue(target, valueUpdated);
}
}
Run Code Online (Sandbox Code Playgroud)
我想这样打电话:
manager.Match<TestClass>(() => original.TestProperty, () => updated.TestProperty);
Run Code Online (Sandbox Code Playgroud) angular ×2
asp.net-core ×2
c# ×2
arrays ×1
asp.net ×1
docker ×1
expression ×1
func ×1
function ×1
javascript ×1
lambda ×1
pg-promise ×1
php ×1
reference ×1
validation ×1