Context. In recent years, some polarization measurements of gamma-ray bursts (GRBs) have been reported, and the polarization-angle (PA) rotation in the prompt emission phase has been found in several bursts. The physical mechanism of the PA evolution is still unclear. In this work, we studied the origin of the PA rotation in a toroidal magnetic field. Aims. We aim to provide an explanation for the PA rotation in GRBs and find the physical conditions that lead to the rotation by 90 degrees in the toroidal magnetic-field (MF) model. Moreover, we present some observable polarization properties in the MF model that can be tested in the future. Methods. We calculated the instantaneous polarization degree (PD) from a top-hat jet with different normalized viewing angles (q = θv/θj), jet opening angles (θj), and jet Lorentz factors (Γ) in three wavebands. When the PD changes between positive and negative values, it means that the PA flips by 90 degrees. On these grounds, we can summarize the range of parameters required for these PA flips. Considering these parameter conditions, we can further estimate the observed rate of the GRBs exhibiting such PA rotations. Results. We find that the PA rotation in the toroidal MF is primarily related to three critical factors: the viewing angle, the jet opening angle, and the jet Lorentz factor. Additionally, the PA can experience flips of 90 degrees twice. The conditions for the flips are q ≳ 0.5 (except for q ≃ 1) and yj = (Γθj)2 ≳ 4. However, the two flips in the PA might not be concurrently observable due to the constraint of flux. Taking these conditions into account and assuming a random orientation between the jet axis and the line of sight (LOS), we obtain a theoretical upper limit (without any constraints) for the observed rate of GRBs in the X-ray or γ-ray band displaying the flips in PA as Rch ≲ 80%. We further constrain the observed rate as Rch ∼ 16% according to the maximal post-flip polarized flux level, where the observed rate of single and double flips each account for ∼8%. It should be noted that the observed rates are different in various wavebands. The observed rate of the second PA flip in the optical bands should be higher than that in the X-ray or γ-ray band since the flux in the optical band declines much slower than that in the X-ray or γ-ray band. Moreover, when the LOS is close to the jet edge (q → 1), it is the easiest case in which to observe the 90-degree PA flip due to the relatively high post-flip polarized flux level. The first and second PA flips in a GRB pulse are most likely to occur at the observed times of tobs ∼ [2 − 3]tpeak and ∼[3 − 4]tpeak, respectively, where tpeak is the peak time of the pulse. It is also noted that the PA flip would not happen before the peak time.