diff --git a/src/viewDirective.js b/src/viewDirective.js
index 6c2bb139a..59c24ccfe 100644
--- a/src/viewDirective.js
+++ b/src/viewDirective.js
@@ -26,26 +26,26 @@
* functionality, call `$uiViewScrollProvider.useAnchorScroll()`.*
*
* @param {string=} onload Expression to evaluate whenever the view updates.
- *
+ *
* @example
- * A view can be unnamed or named.
+ * A view can be unnamed or named.
*
*
- *
- *
+ *
+ *
*
*
*
*
- * You can only have one unnamed view within any template (or root html). If you are only using a
+ * You can only have one unnamed view within any template (or root html). If you are only using a
* single view and it is unnamed then you can populate it like so:
*
- *
+ *
* $stateProvider.state("home", {
* template: "HELLO!
"
* })
*
- *
+ *
* The above is a convenient shortcut equivalent to specifying your view explicitly with the {@link ui.router.state.$stateProvider#views `views`}
* config property, by name, in this case an empty name:
*
@@ -54,33 +54,33 @@
* "": {
* template: "HELLO!
"
* }
- * }
+ * }
* })
*
- *
- * But typically you'll only use the views property if you name your view or have more than one view
- * in the same template. There's not really a compelling reason to name a view if its the only one,
+ *
+ * But typically you'll only use the views property if you name your view or have more than one view
+ * in the same template. There's not really a compelling reason to name a view if its the only one,
* but you could if you wanted, like so:
*
*
- *
+ *
*
* $stateProvider.state("home", {
* views: {
* "main": {
* template: "HELLO!
"
* }
- * }
+ * }
* })
*
- *
+ *
* Really though, you'll use views to set up multiple views:
*
*
- *
- *
+ *
+ *
*
- *
+ *
*
* $stateProvider.state("home", {
* views: {
@@ -93,7 +93,7 @@
* "data": {
* template: ""
* }
- * }
+ * }
* })
*
*
@@ -111,8 +111,8 @@
*
*
*/
-$ViewDirective.$inject = ['$state', '$injector', '$uiViewScroll'];
-function $ViewDirective( $state, $injector, $uiViewScroll) {
+$ViewDirective.$inject = ['$state', '$injector', '$uiViewScroll', '$uiViewName'];
+function $ViewDirective( $state, $injector, $uiViewScroll, $uiViewName) {
function getService() {
return ($injector.has) ? function(service) {
@@ -203,7 +203,7 @@ function $ViewDirective( $state, $injector, $uiViewScroll) {
function updateView(firstTime) {
var newScope,
- name = getUiViewName(attrs, $element.inheritedData('$uiView')),
+ name = $uiViewName(attrs, $element.inheritedData('$uiView'), scope),
previousLocals = name && $state.$current && $state.$current.locals[name];
if (!firstTime && previousLocals === latestLocals) return; // nothing to do
@@ -245,8 +245,8 @@ function $ViewDirective( $state, $injector, $uiViewScroll) {
return directive;
}
-$ViewDirectiveFill.$inject = ['$compile', '$controller', '$state'];
-function $ViewDirectiveFill ($compile, $controller, $state) {
+$ViewDirectiveFill.$inject = ['$compile', '$controller', '$state', '$uiViewName'];
+function $ViewDirectiveFill ($compile, $controller, $state, $uiViewName) {
return {
restrict: 'ECA',
priority: -400,
@@ -254,7 +254,7 @@ function $ViewDirectiveFill ($compile, $controller, $state) {
var initial = tElement.html();
return function (scope, $element, attrs) {
var current = $state.$current,
- name = getUiViewName(attrs, $element.inheritedData('$uiView')),
+ name = $uiViewName(attrs, $element.inheritedData('$uiView'), scope),
locals = current && current.locals[name];
if (! locals) {
@@ -283,13 +283,17 @@ function $ViewDirectiveFill ($compile, $controller, $state) {
}
/**
- * Shared ui-view code for both directives:
- * Given attributes and inherited $uiView data, return the view's name
+ * Service that retrieves a view's name:
+ * Given attributes and inherited $uiView data and scope, return the view's name
*/
-function getUiViewName(attrs, inherited) {
- var name = attrs.uiView || attrs.name || '';
- return name.indexOf('@') >= 0 ? name : (name + '@' + (inherited ? inherited.state.name : ''));
+$UiViewName.$inject = ['$interpolate'];
+function $UiViewName($interpolate) {
+ return function(attrs, inherited, scope) {
+ var name = $interpolate(attrs.uiView || attrs.name || '')(scope);
+ return name.indexOf('@') >= 0 ? name : (name + '@' + (inherited ? inherited.state.name : ''));
+ };
}
+angular.module('ui.router.state').factory('$uiViewName', $UiViewName);
angular.module('ui.router.state').directive('uiView', $ViewDirective);
angular.module('ui.router.state').directive('uiView', $ViewDirectiveFill);