Skip to content

Commit

Permalink
Merge pull request #4 from natealmeida/deep-watch-options
Browse files Browse the repository at this point in the history
Updated ezpOptions watch to deeply watch the options object
  • Loading branch information
igorlino committed May 10, 2016
2 parents 65ba4a4 + 985c1b8 commit 433affb
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions js/angular-ezplus.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

link.$inject = ['$scope', '$element', '$attributes'];
function link($scope, $element, $attributes) {
var bootstrapped = false;
var options = {
onComplete: function () {
if ($scope.onComplete && $scope.onComplete()) {
Expand Down Expand Up @@ -96,10 +97,18 @@
plugin.changeState('enable');
}
});
//updates options dinamically
//updates options dynamically by deeply watching the options object
$scope.$watch('ezpOptions', function (newValue, oldValue) {
angular.extend(options, $scope.ezpOptions);
});
if (!bootstrapped) {
bootstrapped = true;
} else {
var plugin = angular.element($element).data('ezPlus');
angular.extend(options, $scope.ezpOptions);
if (plugin) {
angular.element($element).ezPlus(options);
}
}
}, true);
$scope.$watch('ezpModel', function (newValue, oldValue) {
var image = newValue;
var thumbUrl = (image && image.thumb) || '';
Expand Down

0 comments on commit 433affb

Please sign in to comment.