我正在注意一种快捷方式,可以将字典中的值用作字典中的内部引用.代码显示了我的意思:
var dict = {
'entrance':{
'rate1': 5,
'rate2':10,
'rate3':20,
},
'movies':{
'theDarkKnight':{
'00:00':<entrance.rate1>,
'18:00':<entrance.rate2>,
'21:00':<entrance.rate3>
},
...
};
Run Code Online (Sandbox Code Playgroud)
这是一种偷偷摸摸的方式吗?
当使用barlinechart和nvd3.js时,我得到'属性cx ="NaN"'的值无效.显示图表,但yAxis显示错误的整数值(太低),并且在悬停它时图表上的工具提示不会弹出.输入数据如下.

js部分:
function drawCumulativeChart(selector, jsondata ){
nv.addGraph(function() {
var chart = nv.models.cumulativeLineChart()
.x(function(d) { return d[0] })
.y(function(d) { return d[1] })
.color(d3.scale.category10().range());
chart.xAxis.tickFormat(function (d) {
return d3.time.format("%m/%y")(new Date(d));
});
chart.yAxis.tickFormat(d3.format(',.2f'));
d3.select(selector)
.datum( **jsondata** )
.transition().duration(500)
.call(chart);
nv.utils.windowResize(chart.update);
return chart;
});
}
Run Code Online (Sandbox Code Playgroud)
jsondata:
[{
"key":"usercount",
"values":[
["2011-12-31T23:00:00.000Z",22],
["2012-01-31T23:00:00.000Z",45],
["2012-02-29T23:00:00.000Z",64],
["2012-03-31T22:00:00.000Z",86],
["2012-04-30T22:00:00.000Z",109],
["2012-05-31T22:00:00.000Z",123],
["2012-06-30T22:00:00.000Z",145],
["2012-07-31T22:00:00.000Z",174],
["2012-08-31T22:00:00.000Z",195],
["2012-09-30T22:00:00.000Z",207],
["2012-10-31T23:00:00.000Z",221],
["2012-11-30T23:00:00.000Z",235]
]
}]
Run Code Online (Sandbox Code Playgroud)
数据库原始数据格式:
[time:2012-01-01 00:00:00.0, count:2]
Run Code Online (Sandbox Code Playgroud) 我试图从符合某个标准的对象数组中获取某个对象.
对象的id应该等于scope范围变量$scope.lobbyid.我目前的方法不会将大厅对象传递给控制器.
selected lobby表示站点上活动选项卡的数据.所以容器数组只在站点加载时获取一次.
标记
<div ng-repeat="lobby in lobbies | filter:checkLobbyID(lobby)">
[[lobby.name]]
</div>
Run Code Online (Sandbox Code Playgroud)
调节器
$scope.checkLobbyID = function($lobby) {
return $lobby.lobbyid == $scope.lobbyid;
}
Run Code Online (Sandbox Code Playgroud)
排列
"lobbies": [
{
"isglobal": true,
"lobbyid": 1,
"name": "GLOBAL",
},
{
"isglobal": false,
"lobbyid": 2,
"name": "stackoverflow rules",
},
{
"isglobal": false,
"lobbyid": 3,
"name": "sdadadad",
}
]
Run Code Online (Sandbox Code Playgroud)
临时解决方案是将以下代码添加到tab-switch事件.但这需要一个副本和另一个范围变量.如何用过滤器实现这一目标?
angular.forEach($scope.lobbies, function(lobby) {
if (lobby.lobbyid == $scope.lobbyid)
$scope.currLobby = angular.copy(lobby);
});
Run Code Online (Sandbox Code Playgroud) 我是Grails的新手,我正在拼命想让Spring Security插件运行.我将以下行添加到我的项目中BuildConfig.groovy:
plugins{
...
compile ":spring-security-core:1.2.7.3"
...
}
Run Code Online (Sandbox Code Playgroud)
然后我尝试通过install-plugin命令安装插件.无论我选择哪种方式,我都无法启动项目,因为我已经运行了s2-quickstart脚本(它创建了Spring Security域类和控制器).
我使用PostgreSQL作为数据库并在Windows 7上运行Groovy/Grails Tool Suite,使用Grails版本2.2.1.
这是错误消息:
| Loading Grails 2.2.1
| Configuring classpath.
| Environment set to development.....
| Packaging Grails application....
| Compiling 7 source files.....
| Running Grails application
Configuring Spring Security Core ...
... finished configuring Spring Security Core
| Error 2013-03-29 22:15:17,677 [localhost-startStop-1] ERROR context.GrailsContextLoader - Error initializing the application: Error creating bean with name 'instanceTagLibraryApi': Injection of autowired …Run Code Online (Sandbox Code Playgroud) 我很难将域类对象保存到除默认dataSource之外的dbs中.应该说我可以从日志数据库中读取,但无法保存(UserLog.list()工作).当我运行应用程序时,保存UserLog对象会触发下面的错误.
DataSource.groovy的:
development {
dataSource {
dbCreate = "create-drop"
url="jdbc:postgresql://localhost:5432/db1"
username = "postgres"
password = "postgres"
driverClassName = "org.postgresql.Driver"
}
dataSource_log {
dbCreate = "update"
url="jdbc:postgresql://localhost:5432/db2"
username = "postgres"
password = "postgres"
driverClassName = "org.postgresql.Driver"
}
}
Run Code Online (Sandbox Code Playgroud)
log.UserLog:
class UserLog{
...
static mapping = {
id generator: "hilo"
version false
datasource 'log'
}
}
Run Code Online (Sandbox Code Playgroud)
CONF/BootStrap.groovy中:
import groovy.sql.Sql
import happyfloat.Address
import java.text.DateFormat
import java.text.SimpleDateFormat
import log.UserLog
class BootStrap {
def list = []
def dataSource_log
Random rand = new Random()
def …Run Code Online (Sandbox Code Playgroud) javascript ×3
angularjs ×1
d3.js ×1
filter ×1
grails ×1
grails-2.2 ×1
grails-orm ×1
hibernate ×1
nvd3.js ×1