Skip to content

Latest commit

History

18 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

angular-pubsub

NPM versionBuild StatusCoverage StatusDependenciesDownloads

A publisher/subscribers service for AngularJS.

Currently relies on browserify. Roadmap will include a built file that can be loaded in an index and injected into an angular app without this requirement.

Example Usage

app.js

varmyApp=angular.module('myApp',[]).provider('PubSub',require('angular-pubsub'));

greetingController.js

myApp.controller('GreetingController',['$scope','PubSub',function($scope,PubSub){vargreet=function(newGreeting,oldGreeting){$scope.greeting=newGreeting;// first run --> newGreeting = 'Hello', oldGreeting = undefined// second run --> newGreeting = 'World', oldGreeting = 'Hello'};varuid=PubSub.subscribe('greeting',greet);$scope.$on('$destory',function(){PubSub.unsubscribe(uid);});}]);

loginController.js

myApp.controller('HelloController',['$scope','PubSub',function($scope,PubSub){PubSub.publish('greeting','Hello');PubSub.publish('greeting','World');}]);

About

A publisher/subscriber provider for AngularJS.

Resources

Stars

6 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages