createElement with angularjs

Fabrizio Joaqui
Mega Guru

i want to create a "<p>" element in my html with angulajs how can i do?

if(response.data.prefReport.length){					
					getReport(response.data.prefReport);
				}else {
					//code here...
				}							

 

html:

 

<div>
  
  <div style="width: 60%;margin: auto;padding: 20px 0;margin-bottom: 25px;">
    <sn-record-picker field="c.report" 
                      table="'sys_report'"
                      display-field="'title'"
                      display-fields="'table'"
                      value-field="'sys_id'"
                      default-query="'type=pivot'"
                      search-fields="'title'" 
                      page-size="100">
    </sn-record-picker>
  </div>
  
  <div>
    
  </div>

  <div ng-show="c.data.show_report_widget">
    <div style="display: flex;justify-content: space-between;margin-bottom: 20px;">
      <h4>
        {{c.data.reportTitle}}
      </h4>
      <button class="btn btn-primary" ng-click="c.exportTableToExcel('pvtTable', 'ccccc')">
        Export Excel
      </button>
    </div>
    <div id="output"></div>
  </div>
  
  <div class="loading-container" ng-if="c.data.loadingOn">
    <span class="icon icon-loading icon-lg-spc"></span>
  </div>
  
</div>
1 ACCEPTED SOLUTION

Marc Mouries
ServiceNow Employee
ServiceNow Employee

You can't just create an element. You have to have an HTML element that you populate in your JS.

Where you have your //code here... , set a value, ex: a message. 

//code here... 

response.message = "No report to display" 

in your HTML, add an element such as:

<div ng-if="c.data.message"> 
<p>{{c.data.message"}} </p>
</div>


 

Hit the 👍 Helpful or Accept link ↓ if this answer brings you closer to achieving your goal

View solution in original post

1 REPLY 1

Marc Mouries
ServiceNow Employee
ServiceNow Employee

You can't just create an element. You have to have an HTML element that you populate in your JS.

Where you have your //code here... , set a value, ex: a message. 

//code here... 

response.message = "No report to display" 

in your HTML, add an element such as:

<div ng-if="c.data.message"> 
<p>{{c.data.message"}} </p>
</div>


 

Hit the 👍 Helpful or Accept link ↓ if this answer brings you closer to achieving your goal