我还没弄清楚为什么它不起作用,但我从头开始并得到一个工作版本.它似乎没有必要把system.src.js对前angular脚本标记,步伐下面的答案之一.查看工作版本和Angular 2 教程.
我正在努力学习Angular 2和Express.我一般都遵循本指南.我收到以下错误:
ReferenceError: require is not defined(…) angular2-polyfills.js:1243
Zone.run @ angular2-polyfills.js:1243
zoneBoundFn @ angular2-polyfills.js:1220
lib$es6$promise$$internal$$tryCatch @ angular2-polyfills.js:468
lib$es6$promise$$internal$$invokeCallback @ angular2-polyfills.js:480
lib$es6$promise$$internal$$publish @ angular2-polyfills.js:451
lib$es6$promise$$internal$$publishRejection @ angular2-polyfills.js:401
(anonymous function) @ angular2-polyfills.js:123
Zone.run @ angular2-polyfills.js:1243
zoneBoundFn @ angular2-polyfills.js:1220
lib$es6$promise$asap$$flush @ angular2-polyfills.js:262
Run Code Online (Sandbox Code Playgroud)
编辑:这是GitHub上项目的破碎版本.
我的项目结构如下:
application
|__client
|__app
|__main.ts
|__main.js
|__tsconfig.json
|__typings/ (...)
|__index.html
|__typings.json
|__server
|__server.ts
|__server.js
|__tsconfig.json
|__typings.json
|__node_modules/ (...)
Run Code Online (Sandbox Code Playgroud)
该文件server.ts是这样的:
import …Run Code Online (Sandbox Code Playgroud) 我试图比较一个数字文字与可以返回的函数的返回值nil或数字.考虑一下:
def unreliable
[nil, 42].sample
end
unreliable > 10
Run Code Online (Sandbox Code Playgroud)
这将占50%的时间NoMethodError: undefined method '>' for nil:NilClass.所以我尝试了这个:
unreliable&.(:>, 10)
Run Code Online (Sandbox Code Playgroud)
这种方法可以保证nil我的预期,但是在unreliable返回时我得到了这个42:
NoMethodError: undefined method `call' for 42:Fixnum
Run Code Online (Sandbox Code Playgroud)
我怀疑这与允许每个只存在一个实例的怪癖有关Numeric,请参见此处.而且我知道我可以这样做:
foo = unreliable
foo && foo > 10
Run Code Online (Sandbox Code Playgroud)
但有使用安全导航运营商,数字和方式:>,:<,:==,:+,:-,:/,:*,等?
编辑:Numeric在我的问题中,重点是红鲱鱼.请参阅@Jörg的回答.我把Rails的try语法与安全导航操作符的语法混淆了.
我想访问由Rails创建的数据库中的数据,以供非Ruby代码使用.某些字段使用attr_encrypted访问器,正在使用的库是symmetric-encryptiongem.如果我尝试用例如NodeJS crypto库解密数据,我一直得到"错误的最终块长度"错误.
我怀疑这必须使用字符编码或填充,但我无法根据文档弄清楚.
作为一个实验,我尝试从symmetric-encryptionRuby自己的OpenSSL库中解密数据,我得到一个"错误的解密"错误或同样的问题:
SymmetricEncryption.cipher = SymmetricEncryption::Cipher.new(
key: "1234567890ABCDEF",
iv: "1234567890ABCDEF",
cipher_name: "aes-128-cbc"
)
ciphertext = SymmetricEncryption.encrypt("Hello world")
c = OpenSSL::Cipher.new("aes-128-cbc")
c.iv = c.key = "1234567890ABCDEF"
c.update(ciphertext) + c.final
Run Code Online (Sandbox Code Playgroud)
这给了我一个"糟糕的解密"错误.
有趣的是,数据库中的加密数据可以由symmetric-encryptiongem 解密,但与输出不同SymmetricEncryption.encrypt(并且OpenSSL也不能成功解密它).
编辑:
psql=# SELECT "encrypted_firstName" FROM people LIMIT 1;
encrypted_firstName
----------------------------------------------------------
QEVuQwBAEAAuR5vRj/iFbaEsXKtpjubrWgyEhK5Pji2EWPDPoT4CyQ==
(1 row)
Run Code Online (Sandbox Code Playgroud)
然后
irb> SymmetricEncryption.decrypt "QEVuQwBAEAAuR5vRj/iFbaEsXKtpjubrWgyEhK5Pji2EWPDPoT4CyQ=="
=> "Lurline"
irb> SymmetricEncryption.encrypt "Lurline"
=> "QEVuQwAAlRBeYptjK0Fg76jFQkjLtA=="
Run Code Online (Sandbox Code Playgroud)