Example 2 Given the function $f(x)=x^{2}+2 x \cdot \tan \theta-1, x \in[-1, \sqrt{3}]$, where $\theta \in\left(-\frac{\pi}{2}, \frac{\pi}{2}\right)$
(1) When $\theta=-\frac{\pi}{6}$, find the maximum and minimum values of the function $f(x)$;
(2) Find the range of values for $\theta$ such that $y=f(x)$ is a monotonic function on $[-1, \sqrt{3}]$.
(1) When $\theta=-\frac{\pi}{6}$, $f(x)=x^{2}-\frac{2}{3} \sqrt{3} x-1=\left(x-\frac{\sqrt{3}}{3}\right)^{2}-\frac{4}{3}$
It is clear that when $x=\frac{\sqrt{3}}{3}$, $f(x)$ has a minimum value of $-\frac{4}{3}$; when $x=-1$, $f(x)$ has a maximum value of $\frac{2}{3} \sqrt{3}$.
(2) Since $f(x)=(x+\tan \theta)^{2}-1-\tan ^{2} \theta$, the axis of symmetry of the graph is $x=-\tan \theta$, so $-\tan \theta \leqslant-1$ or $-\tan \theta \geqslant \sqrt{3}$, thus the range of $\theta$ is $\left(-\frac{\pi}{2},-\frac{\pi}{3}\right] \cup\left[\frac{\pi}{4}, \frac{\pi}{2}\right)$.