Improved tab selection logic

Used attributes on header directive to select the correct tab.