how to pass param to js for custom page in drupal 8 ?
You only see the variable in the preprocess hook of the custom template hook_preprocess_test_template(). But you don't need a preprocess hook at all, because you can attach the drupal settings in the controller directly:

return [
  '#theme' =&gt; 'test_template',
  '#attached' =&gt; [
    'drupalSettings' =&gt; [
      'test' =&gt; [
        'data' =&gt; 'test1',
      ],
    ],
  ],
];