Created
December 11, 2015 08:00
-
-
Save netanelgilad/e44c3cc59f7731ce9aa0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<title>subscribe-example</title> | |
</head> | |
<body ng-app="myApp"> | |
<div ng-controller="MyCtrl"> | |
</div> | |
</body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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