OP's ket first equation 

$$\tag{1} \hat{p}|x\rangle ~=~+i\hbar\frac{\partial |x\rangle}{\partial x}$$ 

is explained in eq. (7) of my Phys.SE answer [here](http://physics.stackexchange.com/a/172089/2451). In short, eq. (1) is consistent with the corresponding bra equation
 
$$\langle x |\hat{p} ~=~-i\hbar \frac{\partial \langle x |}{\partial x} $$

via Hermitian conjugation. The bra equation in turn is related to OP's second equation 

$$ \tag{2}\hat{p} ~=~ -i\hbar \frac{\partial }{\partial x} $$

via the standard convention

$$\psi(x)~=~\langle x | \psi \rangle$$

for the wave function.