Question: `EDIT` Helping people understand the question better

Can you call a argument and then use it in jQuery? I was thinking something like:

```
// Notice the "test" argument in the "foo" function
function foo(test) {
  $("#randomDiv").click(function(){
    $(test).toggle();
  });
}

```

Would something like this work?

Answer: 
You can create directive as some other answers or alternatively you can hook it with `ng-submit` and implement logic in the controller.

View:

```
<form name='yourForm' novalidate ng-submit="save(yourForm)">
</form>

```

Controller:

```
$scope.save = function(yourForm) {
  if (!yourForm.$valid) {
    angular.element("[name='" + yourForm.$name + "']").find('.ng-invalid:visible:first').focus();
    return false;
  }
};

```
A minor tweak with what @Sajan said worked for me,

```
angular.element("[name='" + this.formName.$name + "']").find('.ng-invalid:visible:first')[0].focus();

```