AngularJS string replace in HTML
It would be much better to create a method for that purpose:
var addText = 'Attach {0}';
$scope.getButtonLabel = function(label){
return addText.replace('{0}', label.substr(0,label.indexOf("(")));
};
And then use it in your markup:
<button>{{getButtonLabel(header.LabelName)}}</button>
DEMO
Move the javascript to script.js and return the value
angular.module('app', []);
function StringCtrl($scope) {
$scope.headerText = [{
LabelName: 'Submitted Forms (Form (13G), Form (12C) and etc.,)'
}, {
LabelName: 'Planned Plans (Plan (13G), Plan (12C) and etc.,)'
}, {
LabelName: 'Defined Schemes (Scheme (13G), Scheme (12C) and etc.,)'
}, {
LabelName: 'Paid Insurances (Insurance (13G), Insurance (12C) and etc.,)'
}];
$scope.addText = 'Attach {0}';
$scope.getText = function(obj){
return $scope.addText.replace("{0}", obj).replace(/(\(.*\))/g, '')
};
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app="app" ng-controller="StringCtrl">
<div ng-repeat="header in headerText">
<span ng-bind="header.LabelName"></span>
<br />
<button ng-bind="getText(header.LabelName)"></button>
<hr />
</div>
</body>