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 auxillary logic ion. As a proof-of-principle demonstration, we show that we can detect the ground electronic state of a ${^{174}}$Yb$^+$ ion using ${^{171}}$Yb$^+$ as the logic ion. Further, we can distinguish between the ${^{174}}$Yb$^+$ ion being in its ground electronic state versus the metastable ${^{2}}D_{3/2}$ state. We discuss the suitability of this scheme for the detection of rotational states in molecular ions.