i am beginner in angular, so sorry if my question is dummy i have some code like this
var data = [];
$scope.dataObj = {};
resourceTag.getTag({tagName: 'قیچی'}, function(json){
angular.forEach(json, function(value, key){
data.push({
id: value['id'],
text: value['title']
});
});
$scope.dataObj = data;
});
console.log($scope.dataObj);
but in console i get {} (null) but when try this :
var data = [];
$scope.dataObj = {};
resourceTag.getTag({tagName: 'قیچی'}, function(json){
angular.forEach(json, function(value, key){
data.push({
id: value['id'],
text: value['title']
});
});
$scope.dataObj = data;
console.log($scope.dataObj);
});
this is working and console show my data , i guess this issue Related to $digest and $apply or maybe i Commit big mistake
this issue have any best practice (pass scope to out of function !)