0
route: ['category/'+ reports ],
moduleId: 'Admin/report/reportad',
title: reports, nav:  1,

// another js module             
self.actiate(context) 
{ //want to get the router categories(**reports** is an array)details here
}

How to send data from router to activate method in any js module

Andrey Korneyev
  • 26,353
  • 15
  • 70
  • 71
Joel
  • 1
  • 2

1 Answers1

0

you inject the router into the module as it is a singleton object, which should give you access to whatever you need from the router.

//route definition {route: product/:id, moduleId: 'product', title: 'Product Details', nav: false}

define(['knockout','router'], function (ko, router){ 
  var routeData = ko.observable();

  return {
    router: router,
    activate: activate,
  };


  function activate(id){
    routeData(id);
  }
});

One thing to note is that the any paramteres on the route will get injected into the activate method for the module to use.

Nathan Fisher
  • 7,961
  • 3
  • 47
  • 68