While working on an angular js project recently, I encountered a situation involving handling focus and blur events in a textbox. My specific scenario required adding the $ sign when focus is lost from the textbox and removing it when the textbox is focused.
In an attempt to address this, I created a component:
angular.module('myApp').component('dollarText', {
templateUrl: '<input type="text">',
controller: function($scope, iElm, iAttrs){
iElm.bind('change', function(){
iElm.val('$'+iElm.val());
});
}
});
However, I struggled to access the focus event and realized I was approaching it incorrectly. How can I effectively trigger both focus and blur events within an angular component? Is using an angular component the best choice for this task?