Skip to content

Instantly share code, notes, and snippets.

@alexo
Created December 13, 2012 21:34
Show Gist options
  • Save alexo/4280167 to your computer and use it in GitHub Desktop.
Save alexo/4280167 to your computer and use it in GitHub Desktop.
myModule.directive('myComponent', function(mySharedService) {
return {
restrict: 'E',
controller: function($scope, $attrs, mySharedService) {
$scope.$on('handleBroadcast', function() {
$scope.message = 'Directive: ' + mySharedService.message;
});
},
replace: true,
template: '<input>'
};
});
<my-component ng-model="message"></my-component>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment