我已成功将Angular 2(Alpha 44)与D3.js集成:
<html>
<head>
<title>Angular 2 QuickStart</title>
<script src="../node_modules/systemjs/dist/system.src.js"></script>
<script src="../node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js" charset="utf-8"></script>
<script>
System.config({packages: {'app': {defaultExtension: 'js'}}});
System.import('app/app');
</script>
</head>
<body>
<my-app>Loading...</my-app>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
app.js:
/// <reference path="./../../typings/tsd.d.ts" />
import {Component, bootstrap, ElementRef} from 'angular2/angular2';
@Component({
selector: 'my-app',
template: '<h1>D3.js Integrated if background is yellow</h1>',
providers: [ElementRef]
})
class AppComponent {
elementRef: ElementRef;
constructor(elementRef: ElementRef) {
this.elementRef = elementRef;
}
afterViewInit(){
console.log("afterViewInit() called");
d3.select(this.elementRef.nativeElement).select("h1").style("background-color", "yellow");
}
}
bootstrap(AppComponent);
Run Code Online (Sandbox Code Playgroud)
一切都很好.但是ElementRef的Angular 2文档说明如下:
当需要直接访问DOM时,请使用此API作为最后的手段.请使用Angular提供的模板和数据绑定.或者,您可以查看{@link Renderer},它提供了可以安全使用的API,即使不支持直接访问本机元素也是如此.依赖于直接DOM访问会在应用程序和渲染层之间产生紧密耦合,这使得无法将两者分开并将应用程序部署到Web工作者中.
现在问题是如何将D3.js与Renderer API集成?
我正在玩.Net Core并构建一个利用支付API的API.需要将客户端证书添加到双向SSL身份验证请求中.如何使用HttpClient在.Net Core中实现这一目标?
我查看了各种文章,发现HttpClientHandler没有提供添加客户端证书的任何选项.
请指教
我已经从MySQL数据库生成了EF4模型,并且我已经包含了StoredProcedures和Tables.
我知道如何针对EF进行定期检查/更新/获取/删除操作,但我找不到我的StoredProcedures.
这就是我所希望的:
using (Entities context = new Entities())
{
context.MyStoreadProcedure(Parameters);
}
Run Code Online (Sandbox Code Playgroud)
编辑1:
这是没有EF的情况:
sqlStr = "CALL updateGame(?,?,?,?,?,?,?)";
commandObj = new OdbcCommand(sqlStr, mainConnection);
commandObj.Parameters.Add("@id,", OdbcType.Int).Value = inGame.id;
commandObj.Parameters.Add("@name", OdbcType.VarChar, 255).Value = inGame.name;
commandObj.Parameters.Add("@description", OdbcType.Text).Value = ""; //inGame.description;
commandObj.Parameters.Add("@yearPublished", OdbcType.DateTime).Value = inGame.yearPublished;
commandObj.Parameters.Add("@minPlayers", OdbcType.Int).Value = inGame.minPlayers;
commandObj.Parameters.Add("@maxPlayers", OdbcType.Int).Value = inGame.maxPlayers;
commandObj.Parameters.Add("@playingTime", OdbcType.VarChar, 127).Value = inGame.playingTime;
return Convert.ToInt32(executeScaler(commandObj));
Run Code Online (Sandbox Code Playgroud)
PS.如果需要,我可以更改EF版本
编辑1:
CREATE DEFINER=`106228`@`%` PROCEDURE `updateGame`(
inId INT,
inName VARCHAR(255),
inDescription TEXT,
inYearPublished DATETIME,
inMinPlayers INT,
inMaxPlayers INT,
inPlayingTime VARCHAR(127)
)
Run Code Online (Sandbox Code Playgroud) 我使用AsNoTracking()并知道在使用它时禁用了第一级缓存.但如何利用AsNoTracking()提高性能呢?使用它有什么好处?
我需要创建包含随机数据但具有特定大小的文件.我无法找到一种有效的方法.
目前我正在尝试使用BinaryWriter将空char数组写入文件,但在尝试将数组创建为特定大小时,我得到Out of Memory Exception
char[] charArray = new char[oFileInfo.FileSize];
using (BinaryWriter b = new BinaryWriter(File.Open(strCombined, FileMode.Create), System.Text.Encoding.Unicode))
{
b.Write(charArray);
}
Run Code Online (Sandbox Code Playgroud)
建议?
谢谢.
我想将多个模块合并到一个文件中,但我找不到关于如何操作的官方文档.现在我使用下面的方法,它的工作原理,但我想知道以下内容:
的index.html
<script src="require.js"></script>
<script>
requirejs.config({
paths: {
'a': 'test',
'b': 'test'
}
});
require(['a', 'b'], function () {
console.log('a & b loaded');
});
</script>
Run Code Online (Sandbox Code Playgroud)
test.js
console.log('loading test.js');
// I have some init here, like "Avoid `console` errors in IE"
define('a', function () {
console.log('a module');
});
define('b', function () {
console.log('b module');
});
Run Code Online (Sandbox Code Playgroud) 我正在使用isFetchingprop 来禁用输入,但这会变得有用,因为我必须在每个输入字段中保留它.有没有办法禁用整个表单?像标签中的disable属性<form>或什么?
<form>
<input type="text" disabled={this.props.isFetching} />
<input type="text" disabled={this.props.isFetching} />
</form>
Run Code Online (Sandbox Code Playgroud) 我正在尝试遵循Angular 2网站上的官方教程.本教程
我在atom IDE中遇到以下错误:
未使用的label.at第8行第1列
无法分配给'Hero',因为它不是variable.at第8行col 7
以下是我的代码:
import { Component } from '@angular/core';
export class Hero {
id: number;
name: string;
}
hero: Hero = {
id: 1,
name: 'Windstorm'
};
@Component({
selector: 'my-app',
template: `<h1>{{title}}</h1>
<h2>{{hero.name}} details!</h2>`
})
export class AppComponent {
title = 'Tour of Heroes';
hero = 'Windstorm';
}Run Code Online (Sandbox Code Playgroud)
结果如下:
我做错了什么?感谢帮助.
public class Station : IEntitie
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public virtual ICollection<RegulatorySchedule> RegulatoryScheduleDispatchStations { get; set; }
public virtual ICollection<RegulatorySchedule> RegulatoryScheduleDestinationStations { get; set; }
}
public class RegulatorySchedule : IEntitie
{
[Key]
public int Id { get; set; }
public virtual Station DispatchStation { get; set; }
public virtual Station DestinationStation { get; set; }
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<RegulatorySchedule>()
.HasOne(s => s.DestinationStation)
.WithMany(s => s.RegulatoryScheduleDestinationStations)
.OnDelete(Microsoft.EntityFrameworkCore.Metadata.DeleteBehavior.Restrict);
modelBuilder.Entity<RegulatorySchedule>()
.HasOne(s => …Run Code Online (Sandbox Code Playgroud) 我有一个问题,当我从服务器向客户端发送消息时,他们没有按原始顺序到达客户端.我在这里有一个测试功能:
public async Task Hello(string group)
{
await Groups.Add(Context.ConnectionId, group);
await Clients.Group("grp1").Hello("grp1");
await Clients.Group("grp2").Hello("grp2");
await Clients.All.Hello("all");
}
Run Code Online (Sandbox Code Playgroud)
在客户端:
var chanceHub = $.connection.chanceHub;
chanceHub.client.Hello = function (message) {
alert(message);
}
$.connection.hub.start().done(function () {
chanceHub.server.hello("grp1");
});
Run Code Online (Sandbox Code Playgroud)
我希望按此顺序获得2个警报:"grp1"然后"all"但我总是首先得到消息"all".有什么方法可以解决这个问题吗?
c# ×5
.net ×2
angular ×2
javascript ×2
.net-core ×1
asp.net-core ×1
d3.js ×1
forms ×1
html ×1
mysql ×1
reactjs ×1
requirejs ×1
signalr ×1
typescript ×1