How do I set the tab title? How do I set the title of the tab from a controller in Drupal 8? This is the code I am using:

Controller

class myController extends ControllerBase {

    public function node($nId) {
        $nodeObj = Node::load($nId);
        $elements = getRequiredDetails($nodeObj);

        return [
            '#theme'    =&gt; 'my_mod',
            '#title'    =&gt; 'This is the Tab Title'
            '#contents' =&gt; $elements,
            '#attached' =&gt; [
                'library'=&gt; [
                    'my_mod/my_mod',
                ],
            ],
        ];
    }

    /**
    * Returns a page title.
    */
    public function getTitle() {
        $route = \Drupal::routeMatch()-&gt;getCurrentRouteMatch()-&gt;getRouteObject();

        return $route-&gt;getDefaults('#title');
    }
}


Route

my_mod.node:
 path: '/node/{nId}'
 defaults:
   _controller: 'Drupal\my_mod\Controller\myController::node'
   _title_callback: 'Drupal\my_mod\Controller\myController::getTitle'
requirements:
   _permission: 'access content'


But the '#title' in my controller sets the title in the page, not in the tab.  Is there anything I am doing wrong? 

If I put something like die('Title Here'); in getTitle(), it will show in the tab. I need to call that method from the route.
If you use Meta tag module, you can use following method. From this method you can get Meta tag title and other Meta tags for view section also.

my_module.services.yml

services:
my_module.route_subscriber:
class: Drupal\my_module\Routing\RouteSubscriber
tags:
  - { name: event_subscriber }


my_module/src/Routing/RouteSubscriber.php

namespace Drupal\my_module\Routing;

use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;

/**
 * Listens to the dynamic route events.
 */
class RouteSubscriber extends RouteSubscriberBase {

    /**
     * {@inheritdoc}
     */
    protected function alterRoutes(RouteCollection $collection) {

        if ($route = $collection-&gt;get('entity.node.canonical')) {
            $route-&gt;setDefaults(array(
                '_controller' =&gt; 'Drupal\my_module\Controller\MymoduleController::view',
            ));
        }
    }
}


MymoduleController.php

namespace Drupal\my_module\Controller;

use Drupal\Core\Entity\EntityInterface;
use Drupal\node\Entity\Node;
use Drupal\node\Controller\NodeViewController;

class MymoduleController extends NodeViewController {

    public function view(EntityInterface $node, $view_mode = 'full', 
    $langcode = NULL) {

        $elements = getRequiredDetails($node);

        return [
            '#theme'    =&gt; 'your-theme',
            '#contents' =&gt; $elements,
            '#attached' =&gt; [
                'library'=&gt; [
                    'my_content/my_content',
                ],
            ],
        ];
    }
}