AngularJs 有没有办法替换字符串?
我正在尝试做类似的事情:
{{string.replace('some', 'thing')}}
Thanks!
你的片段有效!
demo: http://plnkr.co/edit/yNuNeE5yO3rgKAYfGx48?p=preview
html
<body ng-app="app">
<div>
<div class="container" ng-controller="mainCtrl">
<p>
{{ name.replace('some', 'thing') }}
</p>
</div>
</div>
</body>
js
var app = angular.module('app', []);
app.controller('mainCtrl',function($scope) {
$scope.name = 'this is some';
}
);
输出是this is thing
![enter image description here](https://i.stack.imgur.com/Lzvhh.png)
demo: http://plnkr.co/edit/yNuNeE5yO3rgKAYfGx48?p=preview
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)