I am using angular js with multiple conditions all using the same id. Need to get text just from the condition that is true.
I just found a big bug in an app I'm about to release. I am using angularjs/ionic vs 1 and use allot of conditions in my html. These condition produce great results and show what I want to be shown. However whenever I save the information it fetches the element id, which each condition has the same id, and instead of giving me the text to the visible condition, I get all of them. I need a way to grab the id text only if it's visible. This used to work, unless this was missed during testing. Checking the id in controller.
 function JqliteIds(id) {
       // var myElement = angular.element( document.querySelector( '#some-id' ) );
        var p = angular.element(document.getElementById(id)).text().trim();
        p = p.replace(/(\r\n|\n|\r)/gm, " ");
        p = p.replace(/ +/g, ' ');
        return p;
        //stepTwoFormula = stepTwoFormula.replace(/(\r\n|\n|\r)/gm, " ");
        //stepTwoFormula = stepTwoFormula.replace(/ +/g, ' ');
    }
The html form with multiple conditions. The id is... id="stepOneFormula"
     <div class="item item-text-wrap">
        <div ng-if="level.light">
            <div ng-show="level.stepOne.bleachAdditiveType < 0">
                <p id="stepOneFormula">
                    Mix {{config.productTypes[level.stepOne.productType]}} with
                    <span ng-if="level.stepOne.productType === 1 || level.stepOne.productType === 2">
                        the manufacturer suggested developer or
                    </span> {{level.stepOne.peroxideVolume}} volume / {{level.stepOne.peroxidePercentage}} percent peroxide until it is the consistency of mayonnaise.
                </p>
            </div>
            <div ng-show="level.stepOne.bleachAdditiveType > -1">
                <p id="stepOneFormula">
                    Add approximately {{config.partsInches[level.stepOne.bleachInches]}} of
                    {{config.productTypes[level.stepOne.bleachAdditiveType]}} to {{config.productTypes[level.stepOne.productType]}}. Mix with
                    <span ng-if="level.stepOne.productType === 1 || level.stepOne.productType === 2">
                        the manufacturer suggested developer or
                    </span> {{level.stepOne.peroxideVolume}} volume / {{level.stepOne.peroxidePercentage}} percent peroxide until it is the consistency of mayonnaise.
                </p>
            </div>
        </div>
        <div ng-if="!level.light">
            <p>
                <!--Going Red-->
                <div ng-show="level.stepOne.redRootsTonePercentOne > -1">
                    <div id="stepOneFormula" ng-include="'app/formula-result/service-types/double-process/red-rootsDbl1.html'"></div>
                </div>
                <!--Mixed Levels of gray-->
                <div ng-show="level.stepOne.grayTonePercentFour > -1">
                    <div id="stepOneFormula" ng-include="'app/formula-result/service-types/double-process/gray-mixedDbl1.html'" data="level.stepOne"></div>
                </div>
                <!--Regular Levels-->
                <div ng-show="level.stepOne.grayTonePercentFour === -1 && level.stepOne.redRootsTonePercentOne === -1">
                    <div id="stepOneFormula" ng-include="'app/formula-result/service-types/double-process/genericDbl1.html'"></div>
                </div>
            </p>
        </div>
    </div>
