Here is my Angular $scope.variable.
$scope.users = {
id : '',
fullName : '',
email : '',
profile_picture_url : ''
}
$scope.comments = {
commentId : '',
created_by_current_user : '',
created_by_admin : '',
user_has_upvote : '',
creator : '',
fullName : '',
content : '',
created : '',
modified : '',
upvote_count : '',
profile_picture_url : '',
pings : '',
parent : '',
uniqueId : '',
postId : ''
}
Im just getting the array of objects from the HTTP service and storing as angular variable. Here is my angular controller
$scope.getByPost = function(postId) {
console.log('getpost')
$scope.user = $cookieStore.get('currentApp');
console.log($scope.user.uniqueId);
$scope.getUsers();
appService.getUserByPost($scope.user.uniqueId, postId)
.then(function(data) {
console.log("Comments" + data)
$scope.comments = data;
});
};
$scope.getUsers = function() {
console.log('getpost')
appService.fetchAllUsers().then(function(data) {
console.log("Users" + data)
$scope.users = data;
}, function(error) {
console.log('Error ' + error)
})
};
Now I need to pass these variables to another normal JavaScript file for the DOM Operation. I did like this.
var dom_el = document.querySelector('[ng-controller="appController"]');
var ng_el = angular.element(dom_el);
var ng_el_scope = ng_el.scope();
var commentsArray = ng_el_scope.comments;
var usersArray = ng_el_scope.users;
Not working. please tell me to solve this.