I have a simple question that I think has a pretty simple solution, but somehow I am missing it.
I\'m setting up a simple directive for my app. I\'m leaving the scope pr
The problem in your code is: MachineServices.getByCustomerId
and MachineServices.query
are asynchronous. When you call these functions, data from the server does not arrive yet and these lines
$scope.Machines = data.results;
$scope.pages = data.pages;
are not called yet.
Scope in your link function is bound to the parent's scope. But when the link
function is called, the parent's scope.pages is still undefined (due to asyn)
When we work with angular data-binding, we should be passive, just listen for changes and react accordingly(use $watch, for example), because our code does not know and should not know when the bound property has value or has its value updated. Let angular notify us the changes