yoyo burger yoyo burger - 1 year ago 78
AngularJS Question

AngularJS escaping quotes

I am having a hard time escaping quotes in from the following statement


landmark.name="Duke's Car"

I tried various solutions like:

$scope.escapeQuotes= function(str) {
return str
.replace(/('|\")/g, "\\$1")
.replace(/("|\")/g, "\\$1")

But it does not seem to work. Looks like a simple problem but I am having a hard time finding a solution. Any pointers are welcome.

Answer Source

I'd say use ng-mouseover instead, you don't need to worry about that escaping things



$scope.mouseover = function(name){
   console.log("Value output:", name)