Its quite obvious but cant seem to find an answer. I am using Angular with Asp.net MVC. I can comfortably write views/templates using Razor and link js file in it for controller. It work fine as user request a page, It get served by Asp.net MVC runtime. Problem starts when I want to do SPA. Then I need to define routes. Now my ask is to simply forward Url as is to ASP.net MVC and it can return a view with a reference to angular controller in it, but angular routing forces you to either use pre resolved controller or provide a url to resolve controller. Is there any way by which controller can be picked from the view itself as it has reference to js file having controller definition and also declared it using ng-controller. This way we would be able to use excellent convention based ASP.net MVC routing with Angular SPA and will be much simpler for developers having ASP.net MVC background. To summarize, I dont want to specify controller in route config and simply provide template url to get the view which subsequently has the reference to controller ,hence controller should be resolved from there. I would be seriously disappointed if its not possible
ng-controller
declaration on the view. But keep in mind that all the controllers have to be loaded beforehand at the start of app bootstrapping. On demand loading does not work out of box in Angular. – Chandermani Jul 30 at 10:38requirejs
or something similar. Still you cannot put your controller in view. It has to be a separate script file. Remember the disadvantage of multiple controllers that you perceive may not be the case. In production you combine and minify the script files. – Chandermani Jul 30 at 10:45