The reason the particles go in two different directions is not because of their charge, but because of their spin. When studying quantum mechanics, you will be introduced to the spin operator $S_i$, as well as others such as for orbital angular momentum $L_i$ and total angular momentum $J_i=L_i+S_i$.
The spin operator is a generator of changes in orientation, and an intrinsic property of fundamental particles. In the Stern-Gerlach experiment, the possible spins were +1/2 and -1/2, hence the particles went in two different directions.
On a more sophisticated level (quantum field theory), spin can be viewed as a relativistic effect. The relation becomes apparent when studying the motivation for the Dirac equation and spinors by investing different representations of the Lorentz group.
Professor Binney (Oxford University) has an excellent introduction to quantum mechanics on YouTube which covers the Stern-Gerlach experiment. His book is also available for free online.
PS: An additional property of spin number is that is quantized, i.e. discrete. That is to say, you can only have very specific spin numbers, and the intervals between those numbers are equal.