I just started learning Angularjs 2 days ago. The question confused me for all two days.
I need to make an HTTP request to the server to get some data when the application starts, but I can not find the right moment for this.
I tried to make a controller that calls $http.get() . But that will not work. It seems that the controller will not be created if it has never been used in html (not sure about this).
I also tried to find other ways, but I only found $ http, which is used for the HTTP request. And $http only appears in the controller .
Maybe I need other Angularjs methods? Or should I execute the instance action manually?
source share