Analysis of angular spectrum of radiation in an undulator magnet