【发布时间】:2017-08-26 19:26:28
【问题描述】:
我查看了周围的所有示例并尝试与我的 Ionic 项目集成但失败了。这是我目前所拥有的。
我正在使用使用 creator.ionic.com 创建的项目
我有一个将 JSON 文件加载到的 html 页面
(agentSchedule.html)
<ion-view style="" title="Agent Schedule">
<ion-content class="has-header" overflow-scroll="true" padding="true">
<ion-refresher on-refresh="doRefresh()">
</ion-refresher>
<div ng-controller="agentScheduleCtrl">
<ion-list style="">
<ion-item class="item-icon-right item item-text-wrap item-thumbnail-left" ng-repeat="user in users">
<img ng-src="{{ user.image }}">
<h2>{{ user.fname }} {{ user.lname }}</h2>
<h4>Role : {{ user.jobtitle }}</h4>
<h4>Username : {{ user.username }}</h4><i class="button-icon icon ion-ios-arrow-forward"></i>
</ion-item>
</ion-list>
</div>
</ion-content>
这是该页面的控制器和路由
.controller('agentScheduleCtrl', function($scope, $http, $timeout) {
var url = "http://www.otago.ac.nz/itssd-schedule/mobileappdevice/services/getUsers.php";
var url = "users.json";
$http.get(url).success( function(response) {
$scope.users = response;
});
.state('menu.agentSchedule', {
url: '/page4',
views: {
'side-menu21': {
templateUrl: 'templates/agentSchedule.html',
controller: 'agentScheduleCtrl'
}
}
})
我是另一个页面,我想将用户名传递到,然后在我从那里转到的任何页面上使用
(specificAgentDetails.html)
<ion-view style="" view-title="Agent Specific Schedule">
<ion-content class="has-header" overflow-scroll="true" padding="true">
</ion-content>
</ion-view>
这是该页面的控制器和路由
.controller('specificAgentDetailsCtrl', function($scope) {
})
.state('menu.specificAgentDetailsCtrl', {
url: '/page9',
views: {
'side-menu21': {
templateUrl: 'templates/specificAgentDetailsCtrl.html',
controller: 'specificAgentDetailsCtrl'
}
}
})
如何将 user.username JSON 变量作为全局变量传递到下一页??
任何帮助都会很棒 - 我在兜圈子
【问题讨论】:
-
Angular 是一个 SPA 框架。您应该有 1 个(!!!).html 页面并在其中切换视图,而不是几个 .html 页面。
-
Ionic 的新手,这就是 creator.ionic.com 的制作方式,所以我只是跟随 - 使用我使用过的格式的任何想法??
标签: html angularjs variables ionic-framework ngcordova