Question: I have the following code:

```
<input id="id">
<button data-action="bea" ng-click="Create($('#id1')[0].value);" class="btn">Insert ID</button>
<button data-action="bea" ng-click="Create($('#id2')[0].value);" class="btn">Insert ID</button>

```

In the JS I have:

```
$scope.Create = function (id){
        if (id === undefined) {
            $scope.data = "You must specify an id";
        } else {
                $scope.data = data;
                console.log(data);
            });
        }
    };

```

When the call gets into the Create function the value of the id is undefined.

If I add the following line at the beginging of the Create function everything works ok:

```
id = $('#id')[0].value;

```

If I send a constant value it works:

```
<button data-action="bea" ng-click="Create('SomeID');" class="btn">Insert ID</button>

```

Why is this happening and how can I do that without putting the line of value into the method?

Thanks

Answer: 
My guess is that `$` is not bound to the jQuery function when the `ng-click` value is evaluated, because it is not exposed in the Angular scope.

Solutions to adress this:

* expose the jQuery function in scope somewhere, e.g `$scope.$ = $;` in a controller.
* make the `Create` function parameterless as you suggested, with a `var id = $('#id')[0].value;` at the beginning
* my favorite : avoid using jQuery. If you put some data in the `#id` element, there's probably a more natural and AngularJS-idiomatic way of retrieving it than querying the DOM (e.g an Angular service).

In particular, if the element you're targeting is an `<input>` element, then use the [ngModel](https://docs.angularjs.org/api/ng/directive/ngModel) directive to link the value to a `$scope`property that will be accessible in the controller : 

```
<input ng-model="inputData"/>

```
The JavaScript you are trying to pass as a parameter of the create function is not available in the scope of the Create function.

Try to target the element a different way.

Does that help?