I was wondering how I use the Controller as
syntax in combination with ngRoute
since I cant do ng-controller="Controller as ctrl"
Asked
Active
Viewed 5,929 times
30

Alex
- 9,313
- 1
- 39
- 44

user1703761
- 1,086
- 3
- 11
- 23
2 Answers
40
Or, you can specify a controller assigning like when you create a new directive using controllerAs
.
$routeProvider
.when('/products', {
templateUrl: 'partials/products.html',
controller: 'ProductsController',
controllerAs: 'products'
});

martinjezek
- 421
- 4
- 3
-
7I think your approach is a lot cleaner – Ody Feb 01 '15 at 07:41
-
Exactly, when implementing, please prefer this solution – Marco Klein Feb 13 '16 at 21:30