我想创建一个带角度事件系统的发布/订阅机制.
angular.module("app",[]);
angular.module("app").directive("first", function($rootScope){
return {
template: "First Directive",
link:function(scope,element,attribute){
$rootScope.$broadcast("OnFirstDirectiveCreated", {
"message": "I'm first directive"
});
}
}
})
angular.module("app").directive("second", function($rootScope){
return {
template: "Second Directive",
link:function(scope,element,attribute){
var handler = $rootScope.$on("OnFirstDirectiveCreated",
function (event, args) {
console.log("First Directive Message: " + args.message);
});
}
}
})
Run Code Online (Sandbox Code Playgroud)
如果我像这样设置HTML文档,控制台中不会显示任何消息:
<div ng-app="app">
<first></first>
<second></second>
</div>
Run Code Online (Sandbox Code Playgroud)
如果我先改变订单第一和第二,请在控制台上留言.
<div ng-app="app">
<second></second>
<first></first>
</div>
Run Code Online (Sandbox Code Playgroud)
但我需要第一个指令或内部指令.
<div ng-app="app">
<first></first>
<second></second>
</div>
<div ng-app="app">
<first>
<second></second>
</first>
</div>
Run Code Online (Sandbox Code Playgroud)
我试过了两次$rootScope.$broadcast,$rootScope.$emit但没有发现.
我正在使用requirejs.我的main.js内容如下.
requirejs.config({
async: true,
parseOnLoad: true,
packages: [],
paths: {
jquery: 'https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min'
}
});
require(["login"], function (loginService) {
loginService.login('validUser');
});
Run Code Online (Sandbox Code Playgroud)
现在,我的配置元素很少.但稍后,我将添加包,路径和其他,因此require.config行将增加.

域层通过数据传输对象(DTO)与其他层进行通信.我对DTO感到困惑.
DTO 1位于域和表示层之间.
DTO 2位于域和数据层之间.
我应该在图层之间创建两个不同的DTO对象还是仅创建一个DTO.专业方式是哪种?
我在 Windows 上使用 github。我是 github 的新手,所以我对账户有点困惑。我前段时间(4个月)建立了github。我在 github.com 上有两个 github 帐户
我正在 github.com 上使用 username1 帐户创建一个存储库。存储库名称是test。我正在将我的文件推送到存储库。命令:
我正在 github.com 网站上打开我的 github username1 帐户,并打开 tets 存储库页面,但索引内容由username2修改
我从控制台更改了用户名、电子邮件,但用户名 2 尚未出现。
与ssh有关吗?我能做些什么?我是新的。
实体框架上下文正在为我生成查询.
var query = from c in context.Cities where c.CityID == 3 select c;
var objectQuery=query as System.Data.Objects.ObjectQuery;
Console.WriteLine(objectQuery.ToTraceString());
Run Code Online (Sandbox Code Playgroud)
这将输出以下字符串:
SELECT
[Extent1].[CityID] AS [CityID],
[Extent1].[geom] AS [geom],
[Extent1].[Name] AS [Name],
FROM [dbo].[Cities] AS [Extent1]
WHERE 3 = [Extent1].[CityID]
Run Code Online (Sandbox Code Playgroud)
我的表包括名为geometry的空间列.实体框架不包含几何函数.例如,这是一个几何函数:
SELECT ST_AREA(geom) FROM Cities WHERE CityID = 3
Run Code Online (Sandbox Code Playgroud)
所以我不能像这样使用上下文扩展方法:
context.Cities.Where(....)
Run Code Online (Sandbox Code Playgroud)
是可能的,还是有任何实体框架方法来覆盖几何函数.
我的 Postgresql 9.5 数据库中有一个名为 events 的表。而这张表大约有 600 万条记录。
我正在select count(event_id) from events查询。但是这个查询需要 40 秒。这对于数据库来说是很长的时间。我event_id的表字段是主键和索引。为什么这需要很长时间?(服务器是 ubuntu vm on vmware 有 4cpu)
解释:
"Aggregate (cost=826305.19..826305.20 rows=1 width=0) (actual time=24739.306..24739.306 rows=1 loops=1)"
" Buffers: shared hit=13 read=757739 dirtied=53 written=48"
" -> Seq Scan on event_source (cost=0.00..812594.55 rows=5484255 width=0) (actual time=0.014..24087.050 rows=6320689 loops=1)"
" Buffers: shared hit=13 read=757739 dirtied=53 written=48"
"Planning time: 0.369 ms"
"Execution time: 24739.364 ms"
Run Code Online (Sandbox Code Playgroud) 我想要对我的对象进行搜索并使用BinaryFormatter类.
public static byte[] BinarySerialize(IMessage message)
{
using (var stream = new MemoryStream())
{
var formatter = new BinaryFormatter();
formatter.Serialize(stream, message);
return stream.ToArray();
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我运行代码时,抛出一个异常.
SerializationException:对象未标记为可序列化.
我认为BinaryFormatter引发了这个异常.
我不想标记为[Serializable]我的对象.或者我的图书馆用户可能忘记标记为[Serializable]他们自己的消息.
有没有其他方法二进制序列化我的对象而不使用[Serializable]属性?
我想创建一个触发函数。但我想检查指定的列是否存在。
CREATE FUNCTION MyFunction()
RETURNS trigger AS '
BEGIN
IF NEW.A >= 5 AND NEW.B <= 5 THEN
// Do something ...
END IF;
RETURN NEW;
END' LANGUAGE 'plpgsql'
Run Code Online (Sandbox Code Playgroud)
但我想检查该列是否NEW.A存在。我怎样才能做到这一点?
我有一个字符串数组,并希望使用LINQ将其转换为double数组.我不想使用foreach循环.
var texts = new List<string>
{"-87.98 65", "-86.98 75", "-97.98 78", "-81.98 65"}
Run Code Online (Sandbox Code Playgroud)
至:
var numerics = new List<IEnumerable<double>>
{
new List<double>{-87.98, 65},
new List<double>{86.98, 75},
new List<double>{-97.98 78},
new List<double>{-81.98 65}
}
Run Code Online (Sandbox Code Playgroud)
LINQ有什么简短的方法吗?
我想通过 sql 查询获取统计信息。我的表是这样的:
ID MATERIAL CREATEDATE DEPARTMENT
1 M1 10.10.1980 D1
2 M2 11.02.1970 D2
2 M3 18.04.1971 D3
.....................
.....................
.....................
Run Code Online (Sandbox Code Playgroud)
我怎样才能获得这样的数据计数范围
DEPARTMENT AGE<10 10<AGE<20 20<AGE
D1 24 123 324
D2 24 123 324
Run Code Online (Sandbox Code Playgroud) c# ×4
postgresql ×3
javascript ×2
sql ×2
.net ×1
angularjs ×1
architecture ×1
config ×1
dto ×1
geospatial ×1
gis ×1
git ×1
github ×1
java ×1
jquery ×1
linq ×1
requirejs ×1
triggers ×1