The needle of compass gets deflected by a magnetic field produced by current carrying wire. But the magnitude of the magnetic field produced in different cases are different and sometimes insignificant also, which results in no deflection or the magnetic field is not sufficient enough to attract iron objects nearby when an electric current is switched on through it. But in all the cases magnetic field is produced by current carrying wire may be its a wire or an electric iron.