In order to capture selected text in a browser, try the Rangy library. I have created a small example of how to use it. I'm sure you can expand it to match your needs.
If you need to take action immediately after user select the text (without button), you should listen for mouseup
event. The following directive should help:
angular.module('myModule').directive('watchSelection', function() {
return {
link: function(scope, element) {
element.on('mouseup', function(event) {
var selection = rangy.getSelection();
// do something with selected text
});
}
};
});
You may also find this answer interesting.