我正在尝试使用基于async,hasMany模型属性的值的计算属性,但无法在我的视图中显示它.
MyApp.Foo = DS.Model.extend({
title: DS.attr('string'),
peeps: DS.hasMany('peep', { async: true });
});
MyApp.Peep = DS.Model.extend({
name: DS.attr('string'),
email: DS.attr('string')
});
MyApp.Foo.FIXTURES = [
{ id: 1, title: 'nice', peeps: [1,2] }
];
MyApp.Peep.FIXTURES = [
{ id: 1, name: 'mypeep', email: 'peep@example.com' },
{ id: 2, name: 'mypeep2', email: 'peep2@example.com' }
];
MyApp.FooController = EmberObjectController.extend({
showPeeps: function() {
// This one works for this test data.
// return [{name: 'baz', email: 'bar'}];
var peepList = this.get('content.peeps.[]').then(function(c) {
// This …Run Code Online (Sandbox Code Playgroud) 如果我运行下面的代码并取消注释"setEncoding"行,我收到以下错误:
/usr/local/test-server/test.js:78
res.setEncoding('utf8');
^
Run Code Online (Sandbox Code Playgroud)
TypeError:Object#没有方法'setEncoding'
没有那条线,一切都按预期工作 - 除了浏览器抱怨未声明的字符编码.
在文档,SO,GitHub问题列表或广泛的谷歌搜索中没有任何东西出现任何有用的东西.node.js版本是最新版本:0.8.6
var https = require('https');
var sslPrivateKey = fs.readFileSync('./pk.pem');
var sslCert = fs.readFileSync('./cert.pem');
var sslOpts = { key: sslPrivateKey, cert: sslCert };
var server = https.createServer(sslOpts, function(req, res) {
if ('GET' === req.method) {
res.writeHead(200, {'Content-Type': 'text/plain','charset': 'utf8'});
//res.setEncoding('utf8');
res.write('You are here' + "\n");
res.end();
}
}
server.listen(8080);
Run Code Online (Sandbox Code Playgroud)