diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/umbsections.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/umbsections.directive.js index d5dc36bcbf..5dec6c3586 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/umbsections.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/umbsections.directive.js @@ -60,6 +60,12 @@ function sectionsDirective($timeout, $window, navigationService, treeService, se } }); + scope.$on("appState.sectionState.changed", function (e, args) { + if (args.key === "currentSection") { + scope.currentSection = args.value; + } + }); + //on page resize window.onresize = calculateHeight; diff --git a/src/Umbraco.Web.UI.Client/src/common/services/appstate.service.js b/src/Umbraco.Web.UI.Client/src/common/services/appstate.service.js index 40d24b3472..1714ec7526 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/appstate.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/appstate.service.js @@ -5,6 +5,32 @@ * * @description * Tracks the various application state variables when working in the back office, raises events when state changes. + * + * ##Samples + * + * ####Subscribe to global state changes: + * + *
+ * scope.showTree = appState.getGlobalState("showNavigation");
+ *
+ * scope.$on("appState.globalState.changed", function (e, args) {
+ * if (args.key === "showNavigation") {
+ * scope.showTree = args.value;
+ * }
+ * });
+ *
+ *
+ * ####Subscribe to section-state changes
+ *
+ *
+ * scope.currentSection = appState.getSectionState("currentSection");
+ *
+ * scope.$on("appState.sectionState.changed", function (e, args) {
+ * if (args.key === "currentSection") {
+ * scope.currentSection = args.value;
+ * }
+ * });
+ *
*/
function appState($rootScope) {