【发布时间】:2015-11-20 21:29:58
【问题描述】:
我正在使用 UI-Router 并尝试实现 ngAnimate 模块动画。
ng-enter 工作正常。但是,我没有看到 ng-leave 被添加到 DOM 中。我知道该类将被临时添加和删除,但它没有。
我正在使用 AngularJS 1.4.7 和 UI Router v0.2.15
这是我的代码:
index.html
<div class="row">
<form class="form-horizontal form-left" name="formProfile" novalidate ng-controller="profileController">
<fieldset>
<div id="form-views" ui-view></div>
</fieldset>
</form>
</div>
View1.html(这是将加载到 index.html 中的默认视图)
<p>View 1 State</p>
<a class="btn btn-sm btn-primary btn-block btn-cm" ui-sref="create.view2">Next</a>
<div ui-view></div>
View2.html
<p>View 2 State</p>
<a class="btn btn-sm btn-primary btn-block btn-cm">Finish</a>
app.js
angular.module('profileModule',['ui.router', 'ngAnimate']);
angular.module('profileModule').run(['$state',function($state){
$state.go('create');
}]);
angular.module('profileModule').config(['$stateProvider','$locationProvider',function($stateProvider,$locationProvider){
$stateProvider.state('create', {
url:'/create',
templateUrl: 'view1.html',
controller: 'profileController'
});
$stateProvider.state('create.view2', {
url:'/view2',
templateUrl: 'view2.html',
});
}]);
有什么建议为什么在加载 create.view2 状态时没有将 ng-leave 添加到 <div id="form-views" ui-view></div>?
【问题讨论】:
-
我可能在这里遗漏了一些东西,但是为什么将 ng-leave 添加到 DOM 很重要?
-
为了应用动画,ngAnimation 模块将在加载 dom 时添加该类。
标签: angularjs