Trying to pass an email address to an AngularJS function has been my recent challenge.
Below is a snippet of the code I've been working on.
<script>
//For simplicity, descriptions for the module and service have been omitted
this.sendEmail = function(id, emailAddress){
// The "emailAddress" parameter is required.
};
</script>
<button name="sendEmail" type="button" ng-click='tc.sendEmail({{$id}}, {{$order->email_address}})'>Send Email</button>
I am using Laravel and can confirm that {{$id}}
and {{$order->email_address}}
are correctly populated with the necessary values.
However, attempting this operation results in an error message, Error: $parse:lexerr
Lexer Error
.
angular.js:12520Error: [$parse:lexerr] http://errors.angularjs.org/1.4.8/$parse/lexerr?p0=Unexpected%20nextharacter%20&p1=s%2043-43%20%5B%40%5D&p2=tc.sendEmail(1025%2C%20example1000%40gmail.com)
It's evident that the values being passed are 1025
and
<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d0b5a8b1bda0bcb5e1e0e0e090b7bdb1b9bcfeb3bfbd">[email protected]</a>
. Initially, I tried using backslashes to escape them, but this did not resolve the issue.
Any suggestions would be greatly appreciated.