I am working on Dirac's paper The Lagrangian in Quantum Mechanics. He looks for the analogy between a classical transformation between two sets of coordinates and momenta $p_r$, $q_r$ and $P_r$, $Q_r$ ($r = 1,2,\dots n$) and the transformation in quantum theory between two representations, in which the $q$'s are diagonal to another in which the $Q$'s are.
The transformation function is $\langle q|Q\rangle$. Now he takes an operator $\alpha$ with "mixed representatives" $\langle q|\alpha|Q\rangle$, and using the completeness identity
$$\langle q|\alpha|Q\rangle = \int \langle q|\alpha|q^\prime\rangle \mathrm{d}q^\prime \langle q^\prime|Q\rangle = \int \langle q|Q^\prime\rangle \mathrm{d}Q^\prime \langle Q^\prime|\alpha|Q\rangle$$
He now sets $\alpha = p_r$, and says that from the first integral we find
$$\langle q|p_r|Q\rangle = -i\hbar \frac{\partial}{\partial q_r} \langle q|Q\rangle$$
I don't understand how is the momentum operator now acting on the whole transformation function. And it is clear that that is what it means, since later on the same paper he sets $\langle q|Q\rangle = \exp(iU/\hbar)$ and from this equation he gets
$$\langle q|p_r|Q\rangle = \frac{\partial U}{\partial q_r} \langle q|Q\rangle$$
Just to clarify, I don't understand how is it that the momentum gets out the bra and ket, and once it does, how is it that it is now operating on the transformation.