Skip to content
This repository was archived by the owner on May 21, 2025. It is now read-only.
This repository was archived by the owner on May 21, 2025. It is now read-only.

Unable to get the data with proper format in HTML in angular js #519

Description

@sandythesand

I have chemical name C2H5OH which comes in
{{value.value}}
where value = C2H5OH,

I used the function to replace the 2 and 5 with 2 and 5 with code
{{value.key == 'mol_formula' ? convertChemical(value.value) : value.value}}

The function is-
$scope.convertChemical = function (chemicalName) { var newString = ''; for (i = 0; i < chemicalName.length; i++) { if (chemicalName[i].match(/[\d\.]+/g) != null) { newString += "<sub>" + chemicalName[i] + "</sub>"; } else { newString += chemicalName[i]; } } return newString; }

In output I got the value like

C<sub>2</sub>H<sub>5</sub>OH

but I need it in Chemical format.
Like: C2H5OH

Please help

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions