Harry Styles says his ex-girlfriend helped him overcome anxiety