diff options
Diffstat (limited to 'plugins/CoreHome/angularjs/siteselector/siteselector.directive.js')
-rw-r--r-- | plugins/CoreHome/angularjs/siteselector/siteselector.directive.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/plugins/CoreHome/angularjs/siteselector/siteselector.directive.js b/plugins/CoreHome/angularjs/siteselector/siteselector.directive.js index 06033fbd30..75dbf1e405 100644 --- a/plugins/CoreHome/angularjs/siteselector/siteselector.directive.js +++ b/plugins/CoreHome/angularjs/siteselector/siteselector.directive.js @@ -64,7 +64,10 @@ } return function (scope, element, attrs, ngModel) { - scope.selectedSite = {id: attrs.siteid, name: attrs.sitename}; + if (attrs.siteid && attrs.sitename) { + scope.selectedSite = {id: attrs.siteid, name: attrs.sitename}; + } + scope.model.onlySitesWithAdminAccess = scope.onlySitesWithAdminAccess; if (ngModel) { @@ -78,6 +81,16 @@ } }); + if (ngModel) { + ngModel.$render = function() { + if (angular.isString(ngModel.$viewValue)) { + scope.selectedSite = JSON.parse(ngModel.$viewValue); + } else { + scope.selectedSite = ngModel.$viewValue; + } + }; + } + scope.$watch('selectedSite', function (newValue) { if (ngModel) { ngModel.$setViewValue(newValue); |