I'm passing my scope object to my directive and this works fine! After a get request I update my scope with a property called project. This contains some values like title, content, etc... If I log this everything is working fine but when I try to log scope.project I get the message undefined, but when I log scope I see the project object in the JSON tree... What can happens here?
All console logs show the correct information but I can't access it...
directive:
.directive('project', ['$http', function ($http) {
return {
restrict: 'AEC',
link: function (scope, element, attrs) {
console.log(scope); // gives perfect json object including the project object
console.log(scope.project.content); // gives undefined
}
}
}]);
template:
<div showcontent id="createdcontent"></div>
controller: (This is where I set the scope)
$http.get ('/api/projects/' + id)
.success (function (data) {
$scope.project = data.project;
})
.error (function (data){
console.log("error: " + data);
});
Many thanks