How to modifiy breadcrumbs widget

j_nosbart_knagy
Kilo Contributor

I'm struggling with a somewhat trivial problem: I want to change the breadcrumbs from within the widget server script.

My problem is that the client controller does not seem to pass the data object info to the controller. I started by modifying the existing 'breadcrumbs' widget, but no sucess so far. Do you have any idea where could be the problem? I'm totally new with AngularJS,..

Changes done in the server script are reflected in the client controller and rendering is done accordingly, but in the server script the input object is undefinied, not the c.data as I expected

Any help appreciated... --janos

HTML:

<ul class="nav nav-pills nav-sm">

  <li><a ng-href="?id={{portal.homepage_dv}}">${Home}</a></li>

  <li><i class="fa fa-chevron-right"></i></li>

  <li ng-if="!c.data.breadcrumbs"><a href>{{page.title}}</a></li>

  <li ng-repeat-start="item in c.data.breadcrumbs">

      <a ng-href="{{item.url}}">{{item.label}}</a>

  </li>

  <li ng-if="!$last" ng-repeat-end>

      <i class="fa fa-chevron-right"></i>

  </li>

</ul>

Server script:

(function($sp, input, data, gs) {

  /* populate the 'data' object */

  /* e.g., data.table = $sp.getValue('table'); */

  if (input) {

    // I expected the object of c.data here, but it is undefined:

      gs.log("02 input.oldbr on server: " + JSON.stringify(input.oldbr),"BNJ");

        // CHANGING breadcrumbs works well, eg:

          data.breadcrumbs = [{label: "blah", url: "#"}];

    }

    })($sp, input, data, gs);

Client:

function($scope) {

    var c = this;

    $scope.$on("sp.update.breadcrumbs", function(e,list) {

    c.data.oldbr = list;

  c.server.refresh();

  });

}

2 REPLIES 2

Gurpreet07
Mega Sage

You need to include in function parameters in client controller



    $scope.$on("sp.update.breadcrumbs", function(e,list,oldbr) {


    c.data.oldbr = list;


  c.server.refresh();


Deepak Negi
Mega Sage
Mega Sage