我正试图使我的头脑在切换视图/传递视图到其他视图。
我有一个应用程序,正在调用一个和服API,这是所有的设置与超音速背景,看起来很好。API中有一个字符串和两个对象。我有一个页面,它使用一个名为event的页面在事件的完整列表中调用:
{{ event.eventdescription }
The Event#Index controller is:
angular
.module('event')
.controller("IndexController", function ($scope, Event, supersonic) {
$scope.events = null;
$scope.showSpinner = true;
Event.all().whenChanged( function (events) {
$scope.$apply( function () {
$scope.events = events;
$scope.showSpinner = false;
});
});
});
And all of that displays properly. The issue is when I click on one of those items shown which should go to the specific event I get nothing. And I'm sure I'm doing this wrong or don't understand enough about switching views. I've read many examples, but I'm not getting how it all goes together.这是我的event#show页面。非常通用,只是试着在这里加载任何信息。
<div ng-controller="ShowController">
<super-navbar>
<super-navbar-title>
Show
</super-navbar-title>
</super-navbar>
<div class="padding">
{{ event.eventdescription }}
</div>
</div>而展示员:
angular
.module('event')
.controller("ShowController", function ($scope, Event, supersonic) {
$scope.events = null;
Event.all().whenChanged( function (events) {
$scope.$apply( function () {
});
});
});它总是返回一个空白页。当我检查日志时,上面写着Undefined.undefined,我不知道这意味着什么。
对此的任何见解都将受到极大的赞赏。在医生的报告里我看到了一个叫。
var view = new supersonic.ui.View("bananas#show");
supersonic.ui.layers.push(view);但我不知道怎么用这个?任何洞察力都是值得赞赏的。
所以,我有以下最新消息:
这是我正在工作的event#index。
<div ng-controller="IndexController">
<super-navbar>
<super-navbar-title>
Event Index
</super-navbar-title>
</super-navbar>
<ul class="list" ng-hide="events.length == 0">
<super-navigate view-id="event#show" data-params-id="{{event.id}}" ng-repeat="event in events">
<li class="item item-icon-right">
<h2 ng-bind="event.EventTitles['text']"></h2>
<img ng-src="{{ event.HeadlineImages.src }}" width="100px" height="100px">
<p> {{ event.eventdescription }} </p>
<i class="icon super-ios7-arrow-right"></i>
</li>
</super-navigate>
</ul>
</div>和索引控制器
angular
.module('event')
.controller("IndexController", function ($scope, Event, supersonic) {
$scope.events = null;
Event.all().whenChanged( function (events) {
$scope.$apply( function () {
$scope.events = events;
});
});
});显示html页面。
<div ng-controller="ShowController">
<super-navbar>
<super-navbar-title>
Show
</super-navbar-title>
</super-navbar>
<div class="padding">
<p>
{{event.eventdescription}}
</p>
</div>
</div>The ShowController
angular
.module('event')
.controller("ShowController", function ($scope, Event, supersonic) {
supersonic.ui.views.current.params.onValue( function (Event) {
$scope.events = event.id;
});
Event.find($scope.events).then( function (Event) {
$scope.$apply( function () {
$scope.event = Event;
});
});
});我还更新了structure.coffee
rootView:
location: "event#index"
preloads: [
{
id: "event#show"
}
{
id: "using-the-scanner"
location: "example#using-the-scanner"
}
]任何帮助都是非常感谢的。
发布于 2015-04-14 23:58:53
好吧,经过几个星期的努力,我还是没能让它开始工作。我想我终于能用这个.这里最大的问题似乎是使用Kimono和AppGyver。JSON文件已在Kimono中使用以下方式更新:
function transform(data) {
data.results.collection1 = data.results.collection1.map(function(o) {
o.eventdescription = {
text: o.eventdescription
}
return o;
});
return data;
}这将清理导出/作为API传入App的JSON文件,以便所有部分都是对象。(我知道,也许没什么大不了的,但我只是想让这件事尽可能的干净。)为了让您了解在Kimono修改结果框-> an中使用此脚本的前后:
"EventTitles": {
"href": "http://",
"src": "http://.jpg",
"text": "Lorem Ipsum"
},
"HeadlineImages": {
"href": "http://",
"src": "http://.jpg",
"text": "Lorem Ipsum"
},
"eventdescription":"Lorem Ipsum"
},它将事件描述保留为字符串,而不是对象,然后是后缀:
"EventTitles": {
"href": "http://",
"src": "http://.jpg",
"text": "TEXT"
},
"HeadlineImages": {
"href": "http://",
"src": "http://.jpg",
"text": "TEXT"
},
"eventdescription": {
"text": "TEXT"
}, 因此,在您可以看到所有条目都是"objects“之后,将其运行到Kimono中。您可以在链接中的像素键之后使用&kimmodify=1:
https://www.kimonolabs.com/api/{indentifier}{apikey}&kimmodify=1接下来,正如AppGyver社区向我解释的那样,对于正在创建的JSON / API中的每一项,都需要一个"id“,以便能够使用ShowController在show.html上创建一个合理/可行的url字符串。
在从索引到特定的条目视图时,应该创建类似于/app/tier/showid=123456789的内容。
(您可以在AppGyver中使用调试模式来查找URL,可以通过Mac上的Safari检查器和IOS仿真程序查找。或者在使用Android仿真程序时使用http://localhost:[some port number]/location/of/app的浏览器(推荐的Genymotion)。
因此,要做到这一点,在Kimono中使用API添加&kimhash=1到您的url末尾,在每个use之后,但在修改之前,如下所示:
https://www.kimonolabs.com/api/{indentifier}{apikey}&kimhash=1&kimmodify=1。见:和服API文档-Re:散列。
这就产生了类似的
"EventTitles": {
"href": "http://",
"src": "http://.jpg",
"text": "TEXT"
},
"HeadlineImages": {
"href": "http://",
"src": "http://.jpg",
"text": "TEXT"
},
"eventdescription": {
"text": "TEXT"
},
"hash":"1a2b3c4d5e6f7g8h9z"},为每个条目创建一个随机的“标识符”。
现在,我被困在那里了。...because需要输入的API是:
https://www.kimonolabs.com/api/{indentifier}{apikey}&kimhash=1&kimmodify=1当您在后端配置API时,我看到没有任何区域需要在URL的末尾输入这个新的&kimhash=1&kimmodify=1来调用正确的格式化和id‘call,据我所见,没有这样做的参考。
http://docs.appgyver.com/supersonic/guides/data/other-data-providers/kimono-labs/我觉得这是接下来的最后一步,在解决这一切,并最终能够得到这一点和工作。最后一种显然是重新考虑把id拉到ShowController上,这让我有点自信,如果我能找到最后一部分的话。
有什么主意吗?
发布于 2015-04-01 13:12:12
看起来数据不是在您的ShowController中设置的。我以前对此发表过意见。我认为您需要使用带有<super-navigate>属性和data-params-id的location传递事件的id,或者任何您希望参数名是什么的东西。然后,在您的ShowController中,您可以使用以下方法访问它:
supersonic.ui.views.current.params.onValue( function (values) {
// values.nameOfPropertyPassedInCouldBeEventId
$scope.id = values.id;
});然后,您可能可以执行类似的操作,通过id访问事件:
Event.find($scope.id).then( function (theEvent) {
$scope.$apply( function () {
$scope.event = theEvent;
});
});现在,在您的视图中,有{{ event.eventdescription }}的地方应该有一些数据。
当视图可见时,另一段内容意味着每次看到该视图页时,都会触发:
supersonic.ui.views.current.whenVisible( function () {
// your code for watching events
});https://stackoverflow.com/questions/29380008
复制相似问题