Solution (source code)

= Solution

In the <position representation in quantum mechanics>, $\hat{\mathbf p}=-i\hbar\nabla$. Therefore the <orbital angular momentum> operator gives
$$
\hat L_z=\hat x\hat p_y-\hat y\hat p_x=-i\hbar(x\partial_y-y\partial_x).
$$
At fixed $r,\theta$, the <spherical coordinates> obey $\partial_\phi x=-y$, $\partial_\phi y=x$, and $\partial_\phi z=0$. The <chain rule> consequently gives $\partial_\phi=-y\partial_x+x\partial_y$, hence
$$
\boxed{\hat L_z=-i\hbar\frac{\partial}{\partial\phi}}.
$$
The derivative holds the other two <spherical coordinates> fixed; it is not a derivative along an arbitrary spatial curve.