I have an interface with a "settings" button that opens a modal window. What I want to do is update scope values from the original controller. For example, in the MainController, i define a "default" theme that is used to control the theme in the body tag.
$scope.theme = 'default';
In the controller, I am updating the value of $scope.theme from an input in the view with something like ng-click"changeTheme(newValue)" .. which updates $scope.theme and furthermore, the body's class is reflected by this value.
<body ng-controller="MainController" ng-class="{midnight: theme == 'midnight'}">
Here is the modal code in that controller
$scope.open = function (settings) {
$scope.settings = settings;
$modal.open({
templateUrl: 'myModalContent.html',
backdrop: true,
windowClass: 'modal',
controller: function ($scope, $modalInstance, settings) {
$scope.settings = settings;
$scope.submit = function () {
$modalInstance.dismiss('cancel');
}
},
resolve: {
settings: function () {
return $scope.settings;
}
}
});
};
And in the view ... here's what I have so far.
<script type="text/ng-template" id="myModalContent.html">
<form ng-submit="submit()">
<div class="modal-body">
<label>Label</label>
<input type="text" ng-model="settings.label" />
<label>Value</label>
<input type="text" ng-model="settings.theme" />
</div>
<div class="modal-footer">
<input type="submit" class="btn primary-btn" value="Close" />
</div>
</form>
</script>
This example works when sending back anything that is created in this new $scope.settings object. But what I want is for the new settings object to update the $scope.theme from the main controller as well. What am I missing?
themeand settings. I believe you said it was some logic contained withinchangeTheme()