Sha256: 68c1212565aebc177e44527a9015eaf7b522a81a06a6035c7918c66924bc6e07
Contents?: true
Size: 1.74 KB
Versions: 1
Compression:
Stored size: 1.74 KB
Contents
# Angular.js + Faye ## Usage Add the following to your gemfile: ```ruby gem "angular-faye-rails" ``` Add the following directive to your Javascript manifest file (application.js): ```js //= require angular-faye ``` ## Example ### HTML ```html <script type="text/javascript" src="/js/angular.min.js"></script> <script type="text/javascript" src="/js/angular-faye.js"></script> <script type="text/javascript" src="http://localhost:9292/faye/client.js"></script> <script type="text/javascript" src="/js/app.js"></script> ``` ### JavaScript (app.js) ```js var app = angular.module('myapp', ['faye']); app.factory('Faye', ['$faye', function($faye) { return $faye("http://localhost:9292/faye"); // set faye url in one place }]); this.TestCtrl = function($scope, $http, Faye) { // Publish Faye.publish("/channel-1", {msg: "hello"}); // Subscribe $scope.data = []; Faye.subscribe("/channel-2", function(msg) { $scope.data.push(msg); }); // Get just once (using $q - promise) $scope.data = Faye.get("/channel-3"); }; ``` ### CoffeeScript (the same as above, just in coffee) ```coffee app = angular.module('myapp', ['faye']) app.factory 'Faye', ['$faye', ($faye) -> $faye("http://localhost:9292/faye") # set faye url in one place ] @TestCtrl = ($scope, $http, Faye) -> # Publish Faye.publish("/channel-1", {msg: "hello"}) # Subscribe $scope.data = [] Faye.subscribe "/channel-2", (msg) -> $scope.data.push msg # Get just once (using $q - promise) $scope.data = Faye.get("/channel-3") ``` ## Contributing 1. Fork it 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
angular-faye-rails-0.1.0 | README.md |