Jaguar Land Rover is to build a range of electric cars in the UK, safeguarding thousands of jobs and delivering a huge boost to the industry after a series of setbacks in recent months.