自从将Meteor升级到1.0版以来,是否有其他人从Iron-Router收到以下错误?
如果您知道如何解决此问题,请在此处发布.
路线调度从未呈现.你忘记打电话
this.next()了onBeforeAction?
Router.map(function () {
Router.route('profileShow', {
waitOn: function () {
if (Meteor.user()) {
Meteor.subscribe('userData');
} else {
this.next();
}
},
data: function () {
if (Meteor.user()) {
return {profile: Meteor.user().profile};
}
}
});
});
Run Code Online (Sandbox Code Playgroud) 如何创建自签名SSL证书以在mac 10.9上的本地服务器上使用?
我要求我的localhost充当 https://localhost
我正在使用linkedin API.这里解释了需要本地主机上的ssl的功能. https://developer.linkedin.com/documents/exchange-jsapi-tokens-rest-api-oauth-tokens
简而言之,在客户端授权我的应用访问其数据后,linkedin将向客户端发送持票令牌.linkedin内置的javascript库会自动将此cookie发送到我的服务器/后端.此json文件信息用于用户身份验证.
但是,如果服务器不是https,linkedin将不会发送私人cookie.
与Web应用程序相比,创建移动应用程序是否具有显着优势?
我从以下观点提出这个问题,这偏向于我对手机架构缺乏了解.
用户只需转到一个网址,这就是您的应用,就在服务器上提供服务.
我希望有人能够强调为移动Web应用程序编写特定代码的一些优点.
移动应用程序与Web应用程序相比具有哪些显着优势?
我有一个附加到复选框的事件处理程序.我正在使用自举开关http://www.bootstrap-switch.org/
我试图将状态值(true或false)输入变量,因此我可以将其设置为会话值.
当状态改变时,我可以得到真值或假值(如渲染代码中所示).但是,我想在事件中获得这个价值.请检查我的x变量.
client.js
Template.myTemplate.rendered = function () {
$('input[name="questions"]').bootstrapSwitch('state', true, true);
$('input[name="questions"]').on('switchChange.bootstrapSwitch', function(event, state) {
console.log(state); // true | false
});
Run Code Online (Sandbox Code Playgroud)
HTML:
<template name="myTemplate">
<div class="row">
<input type="checkbox" name="questions" unchecked> Hobby?
</div>
<div class="row">
<input type="checkbox" name="questions" unchecked> Writer?
</div>
Run Code Online (Sandbox Code Playgroud)
我试图将console.log(state)在渲染的代码中打印出来的值放入我的事件中的变量中,这样我就可以将会话值设置为true或false.
Template.myTemplate.events({
'click input': function(event) {
var x = $(this).is(":checked").val();
Session.set("statevalue", x);
console.log(Session.get("statevalue")); // this is not printing out anything
}
});
Run Code Online (Sandbox Code Playgroud) 你如何获得登录用户的_id.我尝试了以下组合,我得到错误或未定义
在用户创建时,用户自动登录到应用程序.这user是 returned由Accounts.onCreateUser用户登录后发生的功能吗?
Accounts.onLogin(function(){
var user = this.userId / Meteor.user() / Meteor.user()._id
console.log(user)
})
Run Code Online (Sandbox Code Playgroud)
我如何检索存在于同一文档的两个不同数组中的元素.
例如.在Posts集合中,文档的字段是"interestbycreator"和"interestbyreader".每个字段都包含用户ID.
'interestbycreator': //an array of ids here. IdA, idB, IdC, IdD, IdE,
'interestbyreader': //an array of ids here. IdB, idE, iDF
Run Code Online (Sandbox Code Playgroud)
基本上我希望找到两个数组中存在的所有id,因此应该是IdB和IdE.
我能够从带有下划线的数组中提取所有值并将它们存储在变量中.他们可以通过这种方式相互比较并返回重复项吗?或者有人可以解释另一种解决方案.
从'interestbyreader中检索所有ID的示例
var interestbypostcreater = Posts.find({_id: Meteor.user().profile.postcreated[0]}, {fields: {interestbyreader: 1}}).fetch();
var interestedReaderIds = _.chain(interestbypostcreator).pluck('interestbyreader').flatten().value();
Run Code Online (Sandbox Code Playgroud)
假设我将另一个数组'interestbycreator'存储在一个名为interestIdcreator的变量中,是否可以比较它们以查找重复项并返回这些重复项?
如何从输入范围中检索并显示滑块值?
我正在使用Meteor并且更喜欢javascript代码.
<input id="slider" type="range" min="50" max="100" step="10" oninput="sliderChange(this.value)">
<output id="sliderVal"> </output>
Run Code Online (Sandbox Code Playgroud)
JavaScript的;
function sliderChange(val) {
document.getElementById('sliderVal').innerHTML = val;
}
Run Code Online (Sandbox Code Playgroud) 用户在输入字段内按Enter键后,我清除值 document.getElementById('text').value = "";
当我使用空格键迭代数组时,这会显示多个具有相同id的输入字段 id='text'
输入第一个输入字段并按回车键后,输入字段清除.
但是,对于在外地进行的情况并非如此.我理解document.getElementById只找到第一个 id.
如何使输入值清除所有输入字段.
'keydown #text': function(event, template) {
if ((27 === event.which) || (13 === event.which)) {
event.preventDefault();
document.getElementById('text').value = "";
}
},
Run Code Online (Sandbox Code Playgroud) 我无法列出服务器上Meteor应用程序中创建的所有集合.
收藏品...... /root/packages/lib/collectionName.js
对collectionName的操作成功.但是,因为我有很多集合,所以我需要一个函数来检索所创建集合的所有名称.
在加载集合之后的服务器函数中,方法执行以下函数;
MyCollection = Mongo.Collection.getAll();
console.log(MyCollection);
[ { name: 'users',
instance:
{ _makeNewID: [Function],
_transform: null,
_connection: [Object],
_collection: [Object],
_name: 'users',
_driver: [Object],
_restricted: true,
_insecure: undefined,
_validators: [Object],
_prefix: '/users/' },
options: undefined },
{ name: 'MeteorToys/Impersonate',
instance:
{ _makeNewID: [Function],
....
Run Code Online (Sandbox Code Playgroud)
Meteor创建的用户集合就在那里.但是所有创建的集合都没有显示,其中3个是Collection2包.
我错过了什么?
如果我需要child_process库并执行一系列命令会有什么影响."meteor mongo"..."db.getCollectionNames()"?
使用bash版本3.2.57(1)-release(x86_64-apple-darwin14)
如何"重新分配"或"更改"读入变量的现有值.
如果用户输入字符串IAmString,我想propInput存储该值iamstring.我只是为了清酒而打印到控制台.
read userInput
echo ${userInput} | tr '[:upper:]' '[:lower:]'
Run Code Online (Sandbox Code Playgroud)