相关疑难解决方法(0)

切换标签/路由时如何保留表单数据?

切换路线时 如何保持应用程序的状态?我发现每次切换标签时都会重新初始化Angular类.

例如. Plunker

import {Component, View, CORE_DIRECTIVES} from 'angular2/angular2'
@Component({
})
@View({
  template: `
 <input class="form-control" [value]="test"> </input>
 <br>
 {{test}}
`
})
export class SearchPage{
    test = `Type something here go to inventory tab and comeback to search tab. Typed data will gone.
    I observed that Angular class is reinitialize every time I switch tabs.`;
    }
}
Run Code Online (Sandbox Code Playgroud)

angular

9
推荐指数
1
解决办法
7396
查看次数

标签 统计

angular ×1