社交教程(Angular2 + Meteor)

时间:2016-03-09 07:40:19

标签: meteor typescript angular angular2-meteor

网址:http://www.angular-meteor.com/tutorials/socially/angular2/search-sort-pagination-and-reactive-vars

当我按照第12.4节的教程进行操作时,编译器总是抱怨: [web.browser] client / parties-list / parties-list.ts(28,40):找不到名字' ReactiveVar

然后,我输入"流星列表"在我的命令行中,我有以下内容:

accounts-password                1.1.4  Password support for accounts

anti:fake                        0.4.1  Random text and data generator

barbatus:ng2-meteor-accounts     0.1.6  Meteor Accounts for Angular2

barbatus:ng2-meteor-accounts-ui  0.1.3  Meteor Accounts UI for Angular2

barbatus:ng2-pagination          0.1.3  Angular2 Pagination Components

es5-shim                         4.1.14  Shims and polyfills to improve ECMAScr...

jquery                           1.11.4  Manipulate the DOM using CSS selectors

meteor-base                      1.0.1  Packages that every Meteor app needs

mobile-experience                1.0.1  Packages for a great mobile user experi...

mongo                            1.1.3  Adaptor for using MongoDB and Minimongo...

reactive-var                     1.0.6  Reactive variable

session                          1.1.1  Session variable

standard-minifiers               1.0.2  Standard minifiers used with Meteor app...

tracker                          1.0.9  Dependency tracker to allow reactive ca...

urigo:angular2-meteor            0.4.4  Angular2 and Meteor integration

明确安装了reactive-var。但是为什么编译器仍然抱怨无法找到ReactiveVar'?

1 个答案:

答案 0 :(得分:0)

确保您的打字正确引用并且是最新的。 我正在使用Meteor 1.2.1和ionic2-meteor,所以我有一个打字文件夹。

确保安装了NPM模块。

npm install typings -g

然后安装流星的打字

  typings install meteor --ambient

  typings install es6-promise --ambient

  typings install es6-shim --ambient

在tsconfig.json

中包含main.d.ts文件
"typings": [
      "typings/ionic2-meteor/ionic-framework/ionic.d.ts",
      "typings/ionic2-meteor/ionic2-meteor.d.ts",
      "typings/angular2-meteor/angular2-meteor.d.ts",
      "typings/main.d.ts"
    ]

确保安装的meteor.d.ts文件包含以下内容:

declare var ReactiveVar: ReactiveVarStatic;
interface ReactiveVarStatic {
    new<T>(initialValue: T, equalsFunc?: Function): ReactiveVar<T>;
}
interface ReactiveVar<T> {
    get(): T;
    set(newValue: T): void;
}

在我的情况下,我不得不更新meteor.d.ts文件(主要和浏览器),因为它们不包含ReactiveVar声明和界面。