-
$ curl https://install.meteor.com/ | sh
-
$ git clone [email protected]:xquadradpi/meteor-angular.git
-
$ npm install
$ meteor npm install
-
$ meteor
Start with Docker:
$ docker-compose up -d
both
Code will executed both client and serverside
client
Clientside code
server
Serverside code
public
Folder for images, css... ( Assets )
tests
Test environment
Folder both > models
Create file group.models.ts
export interface Group {
_id?: string,
name: string,
members: string[],
public: boolean
}
Add:
<br>
`import {Group} from "../../../../both/models/group.models";`
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});
});
Define variables
groupSubs: Subscription;
// RXJS
groups: Observable<Group[]>;
// RXJS
Get entries
this.groupsSub = MeteorObservable.subscribe("groups").subscribe(() => {
this.groups = Groups.find({});
});
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!
});
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 },