Well, I'm having some problems updating a progress bar (which is in a directive) from a controller.
here are some code snippets: my directive:
angular.module('TestApp').directive('orderProgress', ['$window', OrderProgress]);
function OrderProgress($window) {
var directive = {
link: link,
restrict: 'A',
templateUrl: 'OrderProgress.html',
controller: 'ProgressController',
replace: true
};
return directive;
function link(scope, element, attrs) {}
}
controller for directive:
function ProgressController($scope, progressNumberService) {
$scope.progress = progressNumberService.getProgress();
}
progressNumberService just hides the detail for the amount of "progress":
var progress = 20;
var progressServiceInstance = {
incProgress: function() {
progress += 20;
},
decProgress: function() {
progress -= 20;
},
getProgress: function() {
return progress;
}
};
App.value('progressNumberService', progressServiceInstance);
of course the controller:
function Controller($scope, progressNumberService) {
$scope.nextStep = function() {
progressNumberService.incProgress();
};
$scope.prevStep = function() {
progressNumberService.decProgress();
};
}
I've created an example: http://plnkr.co/edit/LtY4ZUG591Kd3mUKEmEF?p=catalogue
So why doesn't the directive get the update from the 'Controller', when the Next/Prev buttons are pressed?