'Error: [$parse:lexerr] Lexer Error: Unexpected next character' on heroku deploy

I had some error while I used ng-click

<a ng-click="#/search/San+Francisco">test</a>

instead of ng-href

<a ng-href="#/search/San+Francisco">test</a>

I hope it might help


If you are using ng-pattern='/some_reg_ex/'. Please save it in some scope variable, say $scope.emailPattern = '/email_regex/'


In general, this occurs when you supply a string literal when angular is expecting an expression or function. A "#" in the string causes the $parse:lexerr error.

In my case, I was setting a string literal to a custom directive attribute, when I should have been using an expression.

Incorrect:

<my-directive my-attr="/foo#bar"></my-directive>

Correct:

<my-directive my-attr="'/foo#bar'"></my-directive>

In this example, the my-attr attribute was set for two-way binding (=) in the custom my-directive. If it was set to "@" the error would not have occurred.

scope: {
  my-attr: "="
}

Tags:

Angularjs