我正在创建一个 Angular2-Meteor 项目。我已将其设置为使用 Angular 2 RC5。在我尝试使用 @injectable() 装饰器添加服务之前,一切都运行良好。一旦它被添加,我就会收到一个流星编译错误:
使用类装饰器时需要反射元数据填充程序
一旦我删除了 @injectable() 装饰器,Meteor 就会编译所有内容,我可以加载我的应用程序。
我安装了 barbatus:angular2-polyfills 包,我认为这是导入所需的 zone.js 和 reflect-metadata 包所需的全部内容。有人建议在 main.ts 顶部使用导入,但这不起作用。
@NgModule 和 @component 装饰器可以正常工作。由于我还没有将服务(使用@injectable 装饰器)连接到我的@ngmodule,我认为这表明Meteor 环境根本没有按预期处理@injectable 装饰器。不管用不用。
任何有关如何解决此问题的建议或想法将不胜感激。
捷通
安装的流星包是:
meteor-base@1.0.4 # Packages every Meteor app needs to have
mobile-experience@1.0.4 # Packages for a great mobile UX
mongo@1.1.12 # The database Meteor supports right now
reactive-var@1.0.10 # Reactive variable for tracker
jquery@1.11.9 # Helpful client-side library
tracker@1.1.0 # Meteor's client-side reactive programming library
standard-minifier-css@1.2.0 # CSS minifier run for production mode
standard-minifier-js@1.2.0 # JS minifier run for production mode
es5-shim@4.6.14 # ECMAScript 5 compatibility for older browsers.
ecmascript@0.5.8 # Enable ECMAScript2015+ syntax in app code
autopublish@1.0.7 # Publish all data to the clients (for prototyping)
insecure@1.0.7 # Allow all DB writes from clients (for prototyping)
angular2-compilers
barbatus:angular2-runtime
practicalmeteor:mocha
xolvio:cleaner
hwillson:stub-collections
dispatch:mocha-phantomjs
shell-server
barbatus:angular2-polyfills
安装的 npm 包package.json
是:
"dependencies": {
"@angular/common": "2.0.0-rc.5",
"@angular/compiler": "2.0.0-rc.5",
"@angular/core": "2.0.0-rc.5",
"@angular/forms": "^0.3.0",
"@angular/platform-browser": "2.0.0-rc.5",
"@angular/platform-browser-dynamic": "2.0.0-rc.5",
"@angular/router": "^3.0.0-rc.1",
"@angular2-material/button": "^2.0.0-alpha.7-4",
"@angular2-material/card": "^2.0.0-alpha.7-4",
"@angular2-material/checkbox": "^2.0.0-alpha.7-4",
"@angular2-material/core": "^2.0.0-alpha.7-4",
"@angular2-material/input": "^2.0.0-alpha.7-4",
"@angular2-material/toolbar": "^2.0.0-alpha.7-4",
"angular2-meteor": "^0.7.0-beta.1",
"angular2-meteor-auto-bootstrap": "^0.6.0",
"angular2-meteor-polyfills": "^0.1.1",
"angular2-meteor-tests-polyfills": "^0.0.2",
"bcrypt": "^0.8.7",
"es6-shim": "0.35.1",
"meteor-node-stubs": "0.2.3",
"reflect-metadata": "0.1.3",
"rxjs": "5.0.0-beta.6",
"zone.js": "0.6.12"
},
"devDependencies": {
"chai": "3.5.0",
"chai-spies": "0.7.1",
"codelyzer": "latest",
"tslint": "latest",
"typescript": "latest",
"typings": "latest"
}