Skip to content

xquadradpi/meteor-angular

Repository files navigation

Kickstarter for Meteor-Angular

Install

  • Install Meteor:

    $ curl https://install.meteor.com/ | sh

  • Clone Project

    $ git clone [email protected]:xquadradpi/meteor-angular.git

  • Change to folder and install all packages

    $ npm install

    $ meteor npm install

  • Start Project

    $ meteor

    Start with Docker:

    $ docker-compose up -d

Structure

both Code will executed both client and serverside
client Clientside code
server Serverside code

public Folder for images, css... ( Assets )
tests Test environment

Models

Create Model

Folder both > models
Create file group.models.ts

  export interface Group {
      _id?: string,
      name: string,
      members: string[],
      public: boolean
  }

Use Models

Add:
<br>
`import {Group} from "../../../../both/models/group.models";`  

Collection

Create Collection

Folder: both>collections
Create file groups.collection.ts

  export const Groups = new MongoObservable.Collection<Group>('groups');
  
  if(Meteor.isClient) {
      Meteor.subscribe("groups");
  }

Add Collection to publication
Folder server > imports > publications:
Create file groups.publication.ts

Meteor.publish("groups", ()  => {
    return Groups.find();
});

Meteor.publish("group", (groupId: string) => {
    return Groups.findOne({groupId});
});

Use Collection

Get list of entries

Define variables
groupSubs: Subscription; // RXJS
groups: Observable<Group[]>; // RXJS

Get entries

 this.groupsSub = MeteorObservable.subscribe("groups").subscribe(() => {
      this.groups = Groups.find({});
  });
Get Single entrie

Define variables
groupSub: Subscription;
group: Group;

Get entries:

this.groupSub = MeteorObservable.subscribe("groups").subscribe(() => {
  Tracker.autorun(() => {
    this.zone.run(() => { 
        this.group = Groups.findOne({_id: this.groupId}); // {groupId] -> only if its ID
    });
  });

Get params:

this.paramsSub = this.route.params.subscribe(params => {
  this.groupId = params['groupId'];
        
  // NEST GET Entries HERE!
});

Routes

Folder client > imports > app
File app.routes.ts

No parameters:
{ path: 'groups', component: GroupListComponent }
With parameters:
{ path: 'groups/edit/:groupId', component: GroupEditComponent }
Multiple parameters:
{ path: 'groups/show/:groupId/:userId', component: GroupShowComponent },

About

kickstarter for meteor-angular

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published