How to pass a variable to $scope in $routeProvider
angularjs, angularjs-scope
Solution
So I think you might be better off using the function support in `templateUrl` to achieve this:
.when('/:zone/edit/:id', {
templateUrl: function(params) {
if (params.zone == "article") {
return 'views/edit-article.html';
}
return 'views/edit.html';
},
controller: 'EditSet'
})
Problem
I need to pass a variable to $scope in $routeProvider. Code is following: ``` .when('/:zone/edit/:id', { templateUrl: 'views/edit.html', controller: 'EditSet' }) .when('/articles/edit/:id', { templateUrl: 'views/edit-article.html', controller: 'EditSet', params: {zone: 'articles'} }) ``` To get param I use `$scope.params.zone`, which works in first case (:zone) and does not work in second case. What should I do in this case?