javascripthtmlcssangularservicenow

Add a dollar symbol before all the column values coming from ng-repeat


I have a few columns in which for one column I need to add '$' symbol before each value of that single column as shown in the below image.

enter image description here

The columns are coming from below script.

<tbody>
          <tr ng-repeat="item in data.list track by item.sys_id">
            <td role="cell" class="pointer sp-list-cell" ng-class="{selected: item.selected}" ng-click="go(item.targetTable, item)" ng-repeat="field in ::data.fields_array" data-field="{{::field}}" data-th="{{::data.column_labels[field]}}"><span ng-if="$first" aria-label="${Open record}: {{::item[field].display_value}}" role="link" tabindex="0">{{::item[field].display_value | limitTo : item[field].limit}}{{::item[field].display_value.length > item[field].limit ? '...' : ''}}</span><span ng-if="!$first">{{::item[field].display_value | limitTo : item[field].limit}}{{::item[field].display_value.length > item[field].limit ? '...' : ''}}</span>
            </td>
            <td><a href="/sys_attachment.do?sys_id={{item.attachment_sys_id}}">{{item.attachment_name}}</a></td>
          </tr>
        </tbody>

Can you please help me.


Solution

  • Assuming you want to modify the second column

    <tbody>
    <tr ng-repeat="item in data.list track by item.sys_id">
        <td role="cell" class="pointer sp-list-cell" ng-class="{selected: item.selected}" ng-click="go(item.targetTable, item)" ng-repeat="field in ::data.fields_array" data-field="{{::field}}" data-th="{{::data.column_labels[field]}}">
            <span ng-if="$first" aria-label="${Open record}: {{::item[field].display_value}}" role="link" tabindex="0">{{::item[field].display_value | limitTo : item[field].limit}}{{::item[field].display_value.length > item[field].limit ? '...' : ''}}</span>
            <span ng-if="!$first">
                <!-- Check if it is the specific column to modify -->
                <span ng-if="data.fields_array.indexOf(field) == 1">$</span>
                {{::item[field].display_value | limitTo : item[field].limit}}{{::item[field].display_value.length > item[field].limit ? '...' : ''}}
            </span>
        </td>
        <td><a href="/sys_attachment.do?sys_id={{item.attachment_sys_id}}">{{item.attachment_name}}</a></td>
    </tr>