【问题标题】:Meteor /w Angular 2.0 db doesn't workMeteor /w Angular 2.0 db 不起作用
【发布时间】:2017-12-13 17:06:46
【问题描述】:

今天我遇到了服务器-客户端框架 Meteor.js,我从他们的初学者教程和 Angular 2.0 开始,我目前已经卡在第三步 "Meteor tutorial"

所以基本上我只需要将它们连接到数据库并测试 Meteor 的功能,问题是即使我能够通过命令行连接到 Meteor 的数据库,在那里插入一个对象,数据也无法获取应用程序本身。 我正在学习教程,

这就是我的 app.ts 文件:

    /// <reference path="../typings/angular2-meteor.d.ts" />

    import {Component, View, NgFor} from 'angular2/angular2';

    import {Parties} from 'collections/parties';

    import {bootstrap} from 'angular2-meteor';

    @Component({
    selector: 'app'
    })

    @View({
    templateUrl: 'client/app.html',
    directives: [NgFor]
    })

  class Socially {
    parties: Array<Object>;

    constructor () {
      Tracker.autorun(zone.bind(() => {

        this.parties = Parties.find().fetch();
      }));

    }
  }

  bootstrap(Socially);

party.ts

     /// <reference path="../typings/angular2-meteor.d.ts" />
     export var Parties = new Mongo.Collection('parties');

app.html

Do you even work ;c
<ul>

    <li *ng-for="#party of parties">
        {{party.name}}
        <p>{{party.description}}</p>

    </li>
</ul>

我也读过一些关于 Meteor 的本地数据库,如果我尝试像这样将对象添加到本地存储中

   Parties._collection.insert({name:"test", description: "test desc"});

数据显示正确,但即使我在服务器数据库中有数据(通过命令行添加)它也不会显示...

【问题讨论】:

    标签: javascript angular meteor


    【解决方案1】:

    如果没有,请尝试添加服务器文件(server/main.ts 和 server/load_parties.ts)。这解决了我的问题。

    【讨论】:

      猜你喜欢
      • 2018-07-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-28
      • 1970-01-01
      • 1970-01-01
      • 2017-05-27
      • 2019-04-29
      相关资源
      最近更新 更多