If you're wanting to know the length of a string in the DOM, then the Angular way of doing it would be to put the functionality in a custom directive.
app.directive('sendLengthOnClick', function() {
return {
scope: {
'localSendLength': '&sendLengthOnClick'
},
link: function(scope, iElement, iAttr) {
iElement.on('click', function() {
var length = iElement.text().length;
scope.localSendLength({length:length});
});
}
}
});
You can then add the attribute send-length-on-click on any element, to send the string length to a function on the parent scope:
<div send-length-on-click="useLength(length)">Click to know the length of this string</div>
You can see this in action in the following Plunker:
http://plnkr.co/edit/Zuk2wnndayvBgYyNXQaL?p=preview
However, I would be curious to know why you would like this. It feels a bit close to calculations based on model data, which would be more usual to be in a service, fetching the length of the string before it hits the DOM, rather than after.