2016-11-16 14 views
0

我们有多个页面每个页面都有表格。 in Page 1当我在一个表单中输入一些数据并点击提交并导航到另一个页面2时,在该页面2中,我向某些字段输入数据,然后导航回页面1,然后单击页面1中的提交并导航到页面2在那段时间内,这些字段没有被清除。我需要使用angularjs清除任何表单域,请帮助。如何清除字段当一页到另一页返回角js

我们面临的问题类似下面

enter image description here

我们需要像下面这样

enter image description here

回答

1

的问题是与缓存视图,您可以禁用缓存, cache-view="false"或者您可以使用输入事件$ionicView.enter手动清理字段。
由您决定在哪里禁用缓存,例如。

Disable cache within state provider 

$stateProvider.state('myState', { 
    cache: false, 
    url : '/myUrl', 
    templateUrl : 'my-template.html' 
}) 

Disable cache with an attribute 

<ion-view cache-view="false" view-title="My Title!"> 
    ... 
</ion-view> 

如果你想手动清洁领域,你将不得不做这样的事情在你的控制器

$scope.$on('$ionicView.enter', function() { 
    $scope.field1 = ''; 
    $scope.field2 = ''; 
    $scope.field3 = ''; 
}); 
+0

,我需要编写代码 –

+0

它可以在状态提供者或直接在 Hosar

+0

谢谢哈萨克它正在运转。 –

相关问题