designerModule.controller('YourViewCtrl', ['$scope', 'propertyService', function ($scope, propertyService) {
propertyService.get()
.then(function (data) {
if (data) {
$scope.properties = propertyService.toAssociativeArray(data.Items);
$scope.selectedLibraryId = $.parseJSON($scope.properties.SelectedLibraryId.PropertyValue);
$scope.selectedLibrary = $.parseJSON($scope.properties.SelectedLibrary.PropertyValue);
}
},
function (data) {
$scope.feedback.showError = true;
if (data)
$scope.feedback.errorMessage = data.Detail;
})
.finally(function () {
$scope.feedback.showLoadingIndicator = false;
});
$scope.$watch('selectedLibraryId', function (newValue, oldValue) {
if (newValue) {
$scope.properties.SelectedLibraryId.PropertyValue = JSON.stringify(newValue);
}
});
$scope.$watch('selectedLibrary', function (newValue, oldValue) {
if (newValue) {
$scope.properties.SelectedLibrary.PropertyValue = JSON.stringify(newValue);
}
});
}]);