-
Notifications
You must be signed in to change notification settings - Fork 3k
/
Copy pathview.js
28 lines (24 loc) · 911 Bytes
/
view.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
$ViewProvider.$inject = [];
function $ViewProvider() {
this.$get = $get;
$get.$inject = ['$rootScope', '$templateFactory'];
function $get( $rootScope, $templateFactory) {
return {
// $view.load('full.viewName', { template: ..., controller: ..., resolve: ..., async: false, params: ... })
load: function load(name, options) {
var result, defaults = {
template: null, controller: null, view: null, locals: null, notify: true, async: true, params: {}
};
options = extend(defaults, options);
if (options.view) {
result = $templateFactory.fromConfig(options.view, options.params, options.locals);
}
if (result && options.notify) {
$rootScope.$broadcast('$viewContentLoading', options);
}
return result;
}
};
}
}
angular.module('ui.router.state').provider('$view', $ViewProvider);