我有一个这样的控制器:
function Ctrl( $scope ){
$scope.str = " Misty Mountain Hop ";
}
像这样的视图:
<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>
因此,如果我尝试使用一种replace
方法,则会出现错误:
Syntax Error: Token 'Mountain' is unexpected ...
问题是:为什么?