Electronic structure of transition-metal hydrides: NiH and PdH