Skip to content

Instantly share code, notes, and snippets.

@netanelgilad
Created December 11, 2015 08:00
Show Gist options
  • Save netanelgilad/e44c3cc59f7731ce9aa0 to your computer and use it in GitHub Desktop.
Save netanelgilad/e44c3cc59f7731ce9aa0 to your computer and use it in GitHub Desktop.
<head>
<title>subscribe-example</title>
</head>
<body ng-app="myApp">
<div ng-controller="MyCtrl">
</div>
</body>
Data = new Mongo.Collection('data');
if (Meteor.isClient) {
angular.module('myApp', ['angular-meteor']).controller('MyCtrl', function($scope) {
$scope.subscribe('pub', () => [1, () => {
console.log("I got data");
}])
});
}
if (Meteor.isServer) {
Meteor.publish('pub', function(param) {
return Data.find({});
});
Meteor.startup(function () {
if (Data.find().count() === 0) {
for (let i = 0; i < 100; i++)
Data.insert({ a: 1});
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment