Angularjs resolve with controller as string

前端 未结 4 1792
醉梦人生
醉梦人生 2020-12-08 15:02

My style of writing angular controllers is like this (using controller name instead of function)

angular.module(\'mymodule\', [
])
    .controller(\'myContro         


        
4条回答
  •  佛祖请我去吃肉
    2020-12-08 15:41

    @TruongSinh answer worked for me and is way nicer than having additional functions in the router. I tweaked it a little as it was returning the deferred object instead of the actual resolved data.

    $routeProvider.when('/someroute', {
        templateUrl: 'partials/someroute.html', 
        controller: 'SomeController',
        resolve: {
           myModel: 'myModel'
        }
    });
    

提交回复
热议问题