Skip to content

Commit 997deb7

Browse files
committed
Merge pull request #2003 from metamatt/matt-view-load-events
fix(ui-view): change $viewContentLoading to pair with $viewContentLoaded
2 parents 17e7757 + f9b43d6 commit 997deb7

File tree

2 files changed

+17
-31
lines changed

2 files changed

+17
-31
lines changed

src/view.js

-26
Original file line numberDiff line numberDiff line change
@@ -36,32 +36,6 @@ function $ViewProvider() {
3636
if (options.view) {
3737
result = $templateFactory.fromConfig(options.view, options.params, options.locals);
3838
}
39-
if (result && options.notify) {
40-
/**
41-
* @ngdoc event
42-
* @name ui.router.state.$state#$viewContentLoading
43-
* @eventOf ui.router.state.$view
44-
* @eventType broadcast on root scope
45-
* @description
46-
*
47-
* Fired once the view **begins loading**, *before* the DOM is rendered.
48-
*
49-
* @param {Object} event Event object.
50-
* @param {Object} viewConfig The view config properties (template, controller, etc).
51-
*
52-
* @example
53-
*
54-
* <pre>
55-
* $scope.$on('$viewContentLoading',
56-
* function(event, viewConfig){
57-
* // Access to all the view config properties.
58-
* // and one special property 'targetView'
59-
* // viewConfig.targetView
60-
* });
61-
* </pre>
62-
*/
63-
$rootScope.$broadcast('$viewContentLoading', options);
64-
}
6539
return result;
6640
}
6741
};

src/viewDirective.js

+17-5
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,6 @@ function $ViewDirective( $state, $injector, $uiViewScroll, $interpolate)
180180
scope.$on('$stateChangeSuccess', function() {
181181
updateView(false);
182182
});
183-
scope.$on('$viewContentLoading', function() {
184-
updateView(false);
185-
});
186183

187184
updateView(true);
188185

@@ -216,6 +213,20 @@ function $ViewDirective( $state, $injector, $uiViewScroll, $interpolate)
216213
newScope = scope.$new();
217214
latestLocals = $state.$current.locals[name];
218215

216+
/**
217+
* @ngdoc event
218+
* @name ui.router.state.directive:ui-view#$viewContentLoading
219+
* @eventOf ui.router.state.directive:ui-view
220+
* @eventType emits on ui-view directive scope
221+
* @description
222+
*
223+
* Fired once the view **begins loading**, *before* the DOM is rendered.
224+
*
225+
* @param {Object} event Event object.
226+
* @param {string} viewName Name of the view.
227+
*/
228+
newScope.$emit('$viewContentLoading', name);
229+
219230
var clone = $transclude(newScope, function(clone) {
220231
renderer.enter(clone, $element, function onUiViewEnter() {
221232
if(currentScope) {
@@ -236,12 +247,13 @@ function $ViewDirective( $state, $injector, $uiViewScroll, $interpolate)
236247
* @name ui.router.state.directive:ui-view#$viewContentLoaded
237248
* @eventOf ui.router.state.directive:ui-view
238249
* @eventType emits on ui-view directive scope
239-
* @description *
250+
* @description
240251
* Fired once the view is **loaded**, *after* the DOM is rendered.
241252
*
242253
* @param {Object} event Event object.
254+
* @param {string} viewName Name of the view.
243255
*/
244-
currentScope.$emit('$viewContentLoaded');
256+
currentScope.$emit('$viewContentLoaded', name);
245257
currentScope.$eval(onloadExp);
246258
}
247259
};

0 commit comments

Comments
 (0)