Update ng-bind-html content dynamically

tpeleg
Tera Expert

Hello experts,

 

I'm trying to fulfil a custom functionality which will change page content dynamically based on value which is looking for the matched html field in a table. the content should be changed on title click.

 

The issue is the html is renderd correctly only on at the first click. 

So, If the user will click of another title, the html will stay on the initial click value.

 

HTML

 

      <div class="wrapper">

  <div class="project-sidebar">

    <a class="filter-links"

    ng-repeat="tite in data.KB"ng-click="onClick(tite.title)">{{tite.title}}</a>

  </div>

</div>   

<div ng-bind-html="::data.con">

</div>                                         

<!--div ng-bind-html="::data.con">

                         

 

</div!-->

 

Client script:

 

api.controller=function($scope) {
/* widget controller */
var c = this;
$scope.onClick = function(name){
//alert(name);
c.data.title = name;
c.server.update();
}
};

 

Server script:

 

(function()  {
  /* populate the 'data' object */
  //data.table = $sp.getValue('u_kb_advanced_view'); */
    data.KB =[];
data.sys_id = $sp.getParameter("kb_sys_id");
    var grKb = new GlideRecord('u_kb_advanced_view');
grKb.addQuery("u_kb_article",data.sys_id)
grKb.query();
    while(grKb.next()){
        var json ={};
        json.title = grKb.u_title.toString();
        json.text = grKb.u_text.toString();
        data.KB.push(json);
    }
 
var grKb2 = new GlideRecord('u_kb_advanced_view');
grKb2.addQuery("u_title",input.title);
grKb2.addQuery("u_kb_article",data.sys_id)
grKb2.query();
    while(grKb2.next()){
//data.con = grKb2.u_text.toString();
gs.log("Tomer - input is: " + input.title,"Tomer");
data.con =grKb2.u_content_html.toString(); //html field
gs.log("Tomer - data con is: " + data.con,"Tomer");
    }
 
})();
 
 
result:
 
 
SP.PNG
 
Table values:
 
Table.PNG

 

Any suggestion how to modify the code so it will work?

 

Thank you,

 

Tomer

 

7 REPLIES 7

are you getting the logs in browser console ? when clicking the button ?

 

 

Please mark as Accepted Solution if this solves your query and HIT Helpful if you find my answer helped you. This will help other community mates too..:)

@Sohithanjan G  this is what I see in browser console when clicking:

 

tpeleg_0-1709634380237.png

 

M_87
Tera Contributor

Hi, encountering same issue. Did you solve this problem?