文本框值消失angulajs

时间:2015-12-22 11:29:21

标签: javascript angularjs state ui-sref

我有以下标签的请求页面。

<p>This page demonstrates 
    <span class="text-danger">nested</span> views.  </p>       
<a ui-sref=".additem" class="btn btn-danger">Add Item sref</a>
<a ui-sref="cloneitem" class="btn btn-primary">Clone Items</a>
<input type="text"/>

我在文本框“Sample text”中输入内容

如果我点击克隆项目,它将重定向到clone.html和内容

<a ui-sref="back" class="btn btn-danger">Back to Request Form</a>
<a ui-sref="clone"  class="btn btn-primary">Clone</a>

如果我点击它,它会显示请求页面,但文本框已清除。

我在app.js中添加了以下内容

routerApp.run(
    ['$rootScope', '$state', '$stateParams',
    function ($rootScope, $state, $stateParams) {
        $rootScope.$state = $state;
        $rootScope.$stateParams = $stateParams;
    }
]);

但我不知道如何使用sref维护状态以及如何传递参数。

0 个答案:

没有答案