STOMP for AngularJS
npm install ng-stomp






> STOMP promised for AngularJS
bash
bower install --save ng-stomp
`#### Add standalone version (dependencies included) to your HTML file
`html
`#### Or add SockJS + STOMP + (minified) ngStomp individually:
`html
`
----$3
`bash
npm install --save ng-stomp
`#### Add standalone version (dependencies included) to your HTML file
`html
`#### Or add SockJS + STOMP + (minified) Stompie individually:
`html
`
----Usage
Inject it in your controller:
`js
angular
// Declare ngStomp as a dependency for you module
.module('app', ['ngStomp']) // use $stomp in your controllers, services, directives,...
.controller('Ctrl', function ($stomp, $scope, $log) {
$stomp.setDebug(function (args) {
$log.debug(args)
})
$stomp
.connect('/endpoint', connectHeaders)
// frame = CONNECTED headers
.then(function (frame) {
var subscription = $stomp.subscribe('/dest', function (payload, headers, res) {
$scope.payload = payload
}, {
'headers': 'are awesome'
})
// Unsubscribe
subscription.unsubscribe()
// Send message
$stomp.send('/dest', {
message: 'body'
}, {
priority: 9,
custom: 42 // Custom Headers
})
// Disconnect
$stomp.disconnect().then(function () {
$log.info('disconnected')
})
})
})
``