US President Donald Trump has criticised American tech companies for building factories in China and hiring workers in India.