我想做的是简单地在元素上附加一些html.我检查了一些链接,我发现了不同的混淆/不工作/非推荐的/ etc解决方案.
使用javascript我会做这样的事情
var d1 = document.getElementsByClassName('one');
d1.insertAdjacentHTML('beforeend', '<div class="two">two</div>');
Run Code Online (Sandbox Code Playgroud)
如何使用typescript/angular2,RC5获得相同的结果?
编辑
具有类的元素.one由外部js生成,我无法修改它
信息:
"System.NotSupportedException was unhandled
Message: An unhandled exception of type 'System.NotSupportedException' occurred in mscorlib.dll
Additional information: A second operation started on this context before a previous asynchronous operation completed. Use 'await' to ensure that any asynchronous operations have completed before calling another method on this context. Any instance members are not guaranteed to be thread safe."
Run Code Online (Sandbox Code Playgroud)
码:
public async Task<IEnumerable<UserLangDTO>> ImportLang(int userId)
{
var userLangs = new List<UserLangDTO>();
using (FirstContext ctx = new FirstContext())
{
if (await (ctx.UserLang.AnyAsync(u => u.UserId …Run Code Online (Sandbox Code Playgroud) 我注意到你不能在角度2组件引导功能中使用 data-spy="affix"
有谁知道如何在角2中使用词缀和scrollspy?(例子)
我正在使用Flipview和DataTemplateSelector在运行时确定要应用于我的控件中显示项目的DataTemplate.
我有两个DataTemplate,一个是静态的,第二个可以由未确定数量的项使用.
目前
我的第一个视图显示: - "这是一个测试 - 内容"
Followed by 18 other views看起来像这样: - " http://www.google.com/ 0" - " http://www.google.com/ 1" - " http://www.google.com/ 2" - 等等直到17日
我想要
要将" http://www.google.com/ " 项目分组为3 on a view.
例如,第二个视图将显示:
第三个视图将显示:
等等..
贝娄是我的代码:
FlipViewDemo.xaml
<Page.Resources>
<DataTemplate x:Key="FirstDataTemplate">
<Grid>
<TextBlock Text="{Binding Content}" Margin="10,0,18,18"></TextBlock>
</Grid>
</DataTemplate>
<DataTemplate x:Key="SecondDataTemplate">
<TextBox Text="{Binding Url}"></TextBox>
</DataTemplate>
<local:MyDataTemplateSelector x:Key="MyDataTemplateSelector"
FirstTextTemplate="{StaticResource FirstDataTemplate}"
SecondTextTemplate="{StaticResource SecondDataTemplate}">
</local:MyDataTemplateSelector> …Run Code Online (Sandbox Code Playgroud) 现在,.NET Core支持OData,7.2.0已发布.但它可以与MongoDB一起使用吗?我已经搜索过,但是找不到任何说法的东西.
编辑:
我找到了一个nuget包https://www.nuget.org/packages/microsoft.aspnetcore.odata,ConfigureServices我在这里添加了这个:
这似乎对我有用:
public void ConfigureServices(IServiceCollection services)
{
...
services.AddOData();
services.AddSingleton<IODataModelManger, ODataModelManager>(DefineEdmModel);
...
}
private ODataModelManager DefineEdmModel(IServiceProvider services)
{
var modelManager = new ODataModelManager();
var builder = new ODataConventionModelBuilder();
builder.EntitySet<TestDTO>(nameof(TestDTO));
builder.EntityType<TestDTO>().HasKey(ai => ai.Id); // the call to HasKey is mandatory
modelManager.AddModel(nameof(Something), builder.GetEdmModel());
return modelManager;
}
Run Code Online (Sandbox Code Playgroud)
调节器
[HttpGet("all")]
public async Task<IQueryable<TestDTO>> Get()
{
// plug your entities source (database or whatever)
var test = await TestService.GetTest();
var modelManager = (IODataModelManger)HttpContext.RequestServices.GetService(typeof(IODataModelManger));
var model = modelManager.GetModel(nameof(Something));
var …Run Code Online (Sandbox Code Playgroud) HTML:
[routerLink]="['', {'scrollTo': '#contact'}]"
Run Code Online (Sandbox Code Playgroud)
TS:
this.route.params.forEach((params: Params) => {
if (params['scrollTo']) {
// some code here
}
});
Run Code Online (Sandbox Code Playgroud)
错误:EXCEPTION:根段不能有矩阵参数
我的routerLink中不能有'scrollTo'参数?
它明显出现在angular 2文档中:https://angular.io/docs/ts/latest/guide/router.html#!#appendix-link-parameters-array
编辑:
似乎没有抱怨:<a [routerLink]="['/crisis-center', { scrollTo: '#contact' }]">Crisis Center</a>.但我需要用我的"根路线".
我创建了一个使用服务层的控制台应用程序.
Program.cs中
public static void Main(string[] args)
{
// Create service collection
var serviceCollection = new ServiceCollection();
ConfigureServices(serviceCollection);
// Create service provider
var serviceProvider = serviceCollection.BuildServiceProvider();
// Entry to run app
serviceProvider.GetService<App>().Run().RunSynchronously();
}
private static void ConfigureServices(IServiceCollection serviceCollection)
{
// Configuration
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", false)
.Build();
serviceCollection.AddOptions();
serviceCollection.Configure<Settings>(options =>
{
//...
});
// Services
serviceCollection.AddTransient<IOneService, OneService>();
serviceCollection.AddTransient<ISecondService, SecondService>();
// Repositories
serviceCollection.AddTransient<MyContext, MyContext>();
serviceCollection.AddTransient<IOneRepository, OneRepository>();
// App
serviceCollection.AddTransient<App>();
// Logger
// Automapper
serviceCollection.AddSingleton(new AutoMapperProfileConfiguration());
serviceCollection.AddScoped<IMapper>(sp =>
new …Run Code Online (Sandbox Code Playgroud) 这是我遇到的错误
错误1无法将类型隐式转换
System.Collections.Generic.IList<Model.DTO.RoleDTO>为System.Collections.Generic.List<Model.DTO.RoleDTO>.存在显式转换(您是否错过了演员?)
我的代码:
IList<RoleDTO> rl = new List<RoleDTO>();
rl.Add(new RoleDTO{ roleId = new Guid("D3DCBCDA-AD61-4764-B5A1-057D654F1C26"),
role = "admin" });
UserDTO user = new UserDTO
{
username = "administrator",
email = "administrator@email.com",
role = rl
};
Run Code Online (Sandbox Code Playgroud)
而型号:
namespace Model.DTO
{
public class UserDTO
{
public string username { get; set; }
public string email { get; set; }
public IList<RoleDTO> role { get; set; }
}
public class RoleDTO
{
public Guid roleId { get; set; }
public …Run Code Online (Sandbox Code Playgroud) 我找到了一篇博客文章,该文章显示了如何以字符串形式接收POSTed JSON。
我想知道在控制器的REST Post方法中执行与以下代码相同的操作的新的本机方法是什么:
public async Task<HttpResponseMessage> Post(HttpRequestMessage request)
{
var jsonString = await request.Content.ReadAsStringAsync();
// Do something with the string
return new HttpResponseMessage(HttpStatusCode.Created);
}
Run Code Online (Sandbox Code Playgroud)
下面的另一个选项对我不起作用,我想是因为我没有Content-Type: application/json在请求标头中使用(无法更改它),并且得到415。
public HttpResponseMessage Post([FromBody]JToken jsonbody)
{
// Process the jsonbody
return new HttpResponseMessage(HttpStatusCode.Created);
}
Run Code Online (Sandbox Code Playgroud) 我有一个跨越孩子的div.
在我的div上我有一个mouseover事件,当我悬停在span我的事件触发器上时.
简单代码:
<div (mouseover)="showOverlay($event, FooBar)" (mouseleave)="showOverlay($event, FooBar)">
<span>{{ someDataHere }}</span>
</div>
public showOverlay($event, op, element): void {
op.toggle($event, element);
$event.preventDefault();
}
Run Code Online (Sandbox Code Playgroud)
我想要的是在孩子身上继续显示我的叠加层,我该如何做到这一点?
c# ×6
angular ×4
.net ×3
asp.net-core ×3
javascript ×2
typescript ×2
asynchronous ×1
generics ×1
json ×1
logging ×1
mongodb ×1
nlog ×1
odata ×1
rest ×1
wpf ×1
xaml ×1