We show that a Banach space $E$ has the weakly compact approximation property if and only if each continuous Banach-valued polynomial on $E$ can be uniformly approximated on compact sets by homogeneous polynomials which are members of the ideal of homogeneous polynomials generated by weakly compact linear operators. An analogous result is established also for the compact approximation property.