Ionic (angular) controller place

I want to make controller for my app (using Ionic framework + Angular), I’ve done some research and there was suggestions to make controller in www/js/MY_CONTROLLER.js but I’m not sure if that would be the best way to do it so I’m asking here from you to help me clear that.

Based on my previous experience when we remove/add apps to ionic (android/ios/electron etc.) also every time we rebuild our app ionic build the www folder gets wiped out and re-build/re-generate (this happened to me before when I was trying to recreate my app in new OS) so I am not 100% behind idea of having my controllers in www folder.

Question

Where should I create my controllers in order to be safe in case of future deployment on new OS?

Source: Angular Questions