I am using a MEAN stack. Upon loading a page, I am pulling data. Based on that data, I am making calculations.
I was trying to do calculations based off the model being $resolved
. I was looking to see if there was an event I could trigger from?
Here is what is being called on ng-init
// Find existing Vital
$scope.findOne = function () {
$scope.vital = Vitals.get({
vitalId: $stateParams.vitalId
});
};
If I try to call my calculate()
right away, like below, it fails because data isn't there yet
// Find existing Vital
$scope.findOne = function () {
$scope.vital = Vitals.get({
vitalId: $stateParams.vitalId
});
$scope.calculate();
};
Try this:
$scope.findOne = function () {
$scope.vital = Vitals.get({
vitalId: $stateParams.vitalId;
$scope.calculate();
$scope.$apply()
});
};