当使用角度1.2而不是1.07时,下面的代码不再有效,为什么?
'use strict';
var app = angular.module('myapp', []);
app.config(['$routeProvider', '$locationProvider',
function($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$routeProvider.
when('/', {
templateUrl: 'part.html',
controller: 'MyCtrl'
}).
otherwise({
redirectTo: '/'
});
}
]);
Run Code Online (Sandbox Code Playgroud)
问题出在注入器配置部分(app.config):
Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.2.0rc1/$injector/modulerr?p0=muninn&p1=Error%…eapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.0rc1%2Fangular.min.js%3A31%3A252)
Run Code Online (Sandbox Code Playgroud)
如果我没记错的话,这个问题始于angular 1.1.6.
是否有任何降价编辑器与rails集成(例如在宝石中)并提供实时预览?
我试图使用聚合框架(使用ruby)并像这样投影日期:
db['requests'].aggregate([
{"$project" => {
_id: 0,
method: '$method',
user: '$user',
year: {'$year' => '$timestamp'}
}}])
Run Code Online (Sandbox Code Playgroud)
该文件就像这样:
{
_id: ObjectId("5177d7d7df26358289da7dfd"),
timestamp: ISODate("2013-04-12T03:58:05+00:00"),
method: "POST",
status: "200",
inputsize: "874",
outputsize: "4981",
user: "131"
}
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:
Mongo::OperationFailure: Database command 'aggregate' failed: (errmsg: 'exception: can't convert from BSON type EOO to Date'; code: '16006'; ok: '0.0').
Run Code Online (Sandbox Code Playgroud)
这很奇怪,因为如果我在与mongorestore导入的完全相同的数据库上运行它,它可以正常工作.
考虑下面的mongo集合示例:
{"_id" : ObjectId("4f304818884672067f000001"), "hash" : {"call_id" : "1234"}, "something" : "AAA"}
{"_id" : ObjectId("4f304818884672067f000002"), "hash" : {"call_id" : "1234"}, "something" : "BBB"}
{"_id" : ObjectId("4f304818884672067f000003"), "hash" : {"call_id" : "1234"}, "something" : "CCC"}
{"_id" : ObjectId("4f304818884672067f000004"), "hash" : {"call_id" : "5555"}, "something" : "DDD"}
{"_id" : ObjectId("4f304818884672067f000005"), "hash" : {"call_id" : "5555"}, "something" : "CCC"}
Run Code Online (Sandbox Code Playgroud)
我想查询这个集合,只得到每个"call_id"的第一个条目,换句话说,我试图获得基于"call_id"的唯一结果.我尝试使用.distinct方法:
@result = Myobject.all.distinct('hash.call_id')
Run Code Online (Sandbox Code Playgroud)
但结果数组将只包含唯一的call_id字段:
["1234", "5555"]
Run Code Online (Sandbox Code Playgroud)
我也需要所有其他领域.是否可以像这样进行查询?:
@result = Myobject.where('hash.call_id' => Myobject.all.distinct('hash.call_id'))
Run Code Online (Sandbox Code Playgroud)
谢谢