我有以下代码:
app.factory(CService.Id,
["$rootScope", "$route", "$routeParams", "$location", "$timeout",
($rootScope, $route, $routeParams, $location, $timeout) =>
new CService($rootScope, $route, $routeParams, $location, $timeout)]);
app.config(['$routeProvider', '$locationProvider',
function ($routeProvider, $locationProvider) {
$routeProvider.
when('/', {
templateUrl: 'page1.html',
controller: 'page1Controller',
controllerAs: 'ctl',
reloadOnSearch: false
}).
when('/', {
templateUrl: 'page2.html',
controller: 'page2Controller',
controllerAs: 'ctl',
reloadOnSearch: false
}).
在page1.html
<div>
<input ng-model="ctl.field">
</div>
现在我想将值field
从page1.html传递给page2.html,例如,当单击重定向按钮(this.location.path(/page2.html)
)时,该怎么做?
谢谢