Ok, so I'm trying to teach myself angular but I'm stuck on something I want to accomplish. Basically, it's a simple form built with UI Bootstrap. I want an info alert box to show up whenever the user gives focus to a textbox, textarea, radio button group, etc. And such alert box will have instructions about this particular field they are filling out. Whenever the user clicks off, the alert box should go away. So far, I have that functionality working with onFocus and onBlur. My problem is, I can't isolate the functionality to work for only the field the user is in. Not unless I create multiple controllers within my app and I find it hard to believe that would be the solution.
How can I declare several alert boxes in the array and call invoke them from their respective input field?
This is my app.j code
var nameApp = angular.module('nameApp', ['ngAnimate', 'ui.bootstrap', '$strap.directives']);
nameApp.controller('InstructionsCtrl', function ($scope, $sce, $timeout) {
$scope.alerts = [];
$scope.addAlert = function () {
$scope.alerts.push({ type: 'info', msg: 'Please input your first name' });
};
$scope.closeAlert = function (index) {
$scope.alerts.splice($scope.alerts.indexOf(this), 1);
};
});
I am including a PLUNKER here
Thanks in advance