Nell'applicazione AngularJS
, ho un problema con la sostituzione delle stringhe in HTML.Stringa AngularJS sostituita in HTML
aspettativa:
Utilizzando la stessa variabile come titolo di sezione e parziale dell'etichetta del pulsante.
Submitted Forms (Form (13G), Form (12C) and etc.,) Attach Submitted Forms Planned Plans (Plan (13G), Plan (12C) and etc.,) Attach Planned Plans Defined Schemes (Scheme (13G), Scheme (12C) and etc.,) Attach Defined Schemes Paid Insurances (Insurance (13G), Insurance (12C) and etc.,) Attach Paid Insurances
Scenario:
ho headerText $scope
variabile. Esso contiene le LabelName
s di ogni sezione:
$scope.headerText = [{
LabelName: 'Submitted Forms (Form (13G), Form (12C) and etc.,)'
}, {
LabelName: 'Planned Plans (Plan (16K), Plan (12C) and etc.,)'
}, {
LabelName: 'Defined Schemes (Scheme (11H), Scheme (12C) and etc.,)'
}, {
LabelName: 'Paid Insurances (Insurance (10G), Insurance (12C) and etc.,)'
}];
Questo LabelName
dovrebbe essere il titolo per ogni sezione e la stessa LabelName
devono essere utilizzati per il testo etichetta del pulsante con il testo Attach
e anche bisogno di rimuovere il testo tra le parentesi.
Così nel file HTML, ho provato il codice qui sotto per ottenere il risultato:
<div ng-repeat="header in headerText">
<span ng-bind="header.LabelName"></span>
<br />
<button>{{addText.replace("{0}", header.LabelName).replace(/(\(.*\))/g, '')}}</button>
<hr />
</div>
dire, io voglio sostituire il contenuto con le staffe insieme con lo spazio vuoto
(Form (13G), Form (12C), ecc,)
da
moduli inviati (Form (13G), Form (12C), ecc,)
e da usare che in testo dell'etichetta del pulsante.
Ho provato il regexp .replace(/(\(.*\))/g, '')
, ma non supporta.
Esiste un modo per ottenere ciò nello stesso HTML
.
La mia aspettativa attuale è quello di raggiungere il 'regexp' in html per sé, questo è la speranza non è possibile fare in html.This va bene .. – Arulkumar
@Arulkumar Per javascript codice complesso che è meglio creare un metodo nel controller e chiamarlo dalla vista. – anpsmn
sì, capisco la complessità. Questa correzione è utile. – Arulkumar