Skip to content

Commit

Permalink
private fix to issue angular-ui#552
Browse files Browse the repository at this point in the history
  • Loading branch information
sayeed-anjum committed Jan 3, 2014
1 parent b92207a commit a0aefba
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/viewDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ function $ViewDirective( $state, $compile, $controller, $injector, $ui

var directive = {
restrict: 'ECA',
priority: 9000,
terminal: true,
compile: function (element, attrs) {
var initial = element.html(),
isDefault = true,
Expand All @@ -78,14 +80,16 @@ function $ViewDirective( $state, $compile, $controller, $injector, $ui

element.prepend(anchor);

return function ($scope) {
var inherited = parentEl.inheritedData('$uiView');
return function ($scope, $element) {
var $parent = $element.parent();
var inherited = $parent.inheritedData('$uiView');
$element.prepend(anchor);

var currentScope, currentEl, viewLocals,
name = attrs[directive.name] || attrs.name || '',
onloadExp = attrs.onload || '',
autoscrollExp = attrs.autoscroll,
renderer = getRenderer(element, attrs, $scope);
renderer = getRenderer($element, attrs, $scope);

if (name.indexOf('@') < 0) name = name + '@' + (inherited ? inherited.state.name : '');
var view = { name: name, state: null };
Expand Down Expand Up @@ -121,16 +125,13 @@ function $ViewDirective( $state, $compile, $controller, $injector, $ui
function updateView(shouldAnimate) {
var locals = $state.$current && $state.$current.locals[name];

if (isDefault) {
isDefault = false;
element.replaceWith(anchor);
}
$element.replaceWith(anchor);

if (!locals) {
cleanupLastView();
currentEl = element.clone();
currentEl.html(initial);
renderer(shouldAnimate).enter(currentEl, parentEl, anchor);
renderer(shouldAnimate).enter(currentEl, $parent, anchor);

currentScope = $scope.$new();
$compile(currentEl.contents())(currentScope);
Expand All @@ -143,7 +144,7 @@ function $ViewDirective( $state, $compile, $controller, $injector, $ui

currentEl = element.clone();
currentEl.html(locals.$template ? locals.$template : initial);
renderer(true).enter(currentEl, parentEl, anchor);
renderer(true).enter(currentEl, $parent, anchor);

currentEl.data('$uiView', view);

Expand Down

0 comments on commit a0aefba

Please sign in to comment.