Hello,
i have a big problem. I want to use a scope variable in a rest call but i
dont know how. In the html i can use the article_id but not in a
subfunction. How i can declare the variable as global or how i can use the
variable in my second function?
articlepage_module.controller('ArticleCtrl',
function ($scope, $http, $routeParams, $route)
{
var article_id;
$scope.$on('$routeChangeSuccess', function(Event, routeData){
$scope.article_id = routeData.params.article_id;
article_id = routeData.params.article_id;
//output 1 -->current article page
console.log(routeData.params.article_id);
});
//output undefined
console.log(article_id);
$http({method: 'GET', url: 'artikel/index.php', params:
{'article_id': article_id}}).success(function(data)
{
$scope.article_details = data; // response data
});
}
);
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.