在多个实例angularjs中替换字符串

时间:2014-08-27 19:53:46

标签: angularjs

我有以下简单的html

<body ng-app="mainModule">
<div ng-controller="mainController">
<input type="text" ng-model="textValue" ng-change="onTextChange(textValue)"/>
{{isTextChanged|ch}}
</div>
</body>

的js

angular.module("mainModule", [])
   .filter('ch', function() {
       return function(input) {
           input = input.replace('a', '');
           return input;
       };
   })
   .controller("mainController", function ($scope)
   {
       $scope.onTextChange = function (txt)
       {
           $scope.isTextChanged = txt
       };

   });

我面临的问题是角度只会改变字母的第一个实例&#39; a&#39;

0 个答案:

没有答案
相关问题