Blog- AngularJS-Simple-service-with-broadcast
by beltiste
HTML
<div ng-app="eventsApp">
<div ng-controller="EventCtrl">
<div>
ControllerA.X = {{show}}<br/>
<a ng-click="open()">open</a><br>
</div>
<hr/>
<div>
ControllerB.X = {{data}}<br/>
<a ng-click="compile()">compile</a><br>
</div>
</div>
</div>
CSS
</style> <!-- Ugly Hack due to jsFiddle issue: http://goo.gl/BUfGZ -->
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.min.js"></script>
<style>
CoffeeScript
angular.module('eventsApp', [])
angular.module('eventsApp', [])
.controller 'EventCtrl', ['$scope', '$http', ($scope, $http) ->
$scope.eventData = title: 'Test'
$scope.show = true
$scope.data = ''
$scope.open = ->
$scope.compile()
$scope.shouldBeOpen = true
return
$scope.close = ->
$scope.shouldBeOpen = false
return
$scope.compile = ->
$http.post('/echo/html/', ''
).success((data, status, headers, config) ->
$scope.image = data
$scope.show = true
return
).error (data, status, headers, config) ->
$scope.status = status
return
]