We present a quantum logic scheme to detect atomic and molecular ions in different states of angular momentum based on their magnetic
g factors. The state-dependent magnetic
g factors mean that electronic, rotational, or hyperfine states may be distinguished by their Zeeman splittings in a given magnetic field. Driving motional sidebands of a chosen Zeeman splitting enables reading out the corresponding state of angular momentum with an auxiliary logic ion. As a proof-of-principle demonstration, we show that we can detect the ground electronic state of a
174Yb+ ion using
171Yb+ as the logic ion. Further, we can distinguish between the
174Yb+ ion being in its ground electronic state versus the metastable
2D3/2 state. We discuss the suitability of this scheme for the detection of rotational states in molecular ions.