Here I have a string with spaces, and I would like to replace the space(s) to a single dash '-'.
var card = "A World Elite Warrior";console.log("card = " + card.toLowerCase().replace(/ /g,‘-’));
The output is a-world-elite-warrior, but I just want to use it in the html template as a angularjs expression like this:
<img ng-src=“images/cards/{{card.toLowerCase().replace(/ /g,‘-’)}}.png”
And it can not work, the error message is:
Error: [$parse:syntax] Syntax Error: Token ‘/’ not a primary expression at column 61 of the expression
#angular.js #regex