I have a controller like this:
function Ctrl( $scope ){
$scope.str = " Misty Mountain Hop ";
}
And a view like this:
<div ng-controller="Ctrl">
<p>{{ str }}</p> <!-- This one is ok -->
<p>{{ str.split( "Mountain")[0] }}</p> <!--Even this one is fine too -->
<p>{{ str.replace( /Mountain/ , "Plain" ) }}</p> <!-- This one is bad -->
</div>
So if i try to use a replace method , it gives an error:
Syntax Error: Token 'Mountain' is unexpected ...
The question is : Why?
RegExpconstructor:str.replace(new RegExp('Mountain'), 'Plain'). Note that there are no delimiters, you need to double all backslashes and modifiers go in a second parameter see MDNView(MVC) only