简体   繁体   English

AppGyver类固醇超音速视图

[英]AppGyver Steroids Supersonic Views

I'm trying to get my head around switching views / passing views to another view. 我正在设法切换视图/将视图传递到另一个视图。

I have an app that is calling in a kimono API, that's all setup with the supersonic background and looks fine. 我有一个正在使用和服API的应用程序,所有应用程序都具有超音速背景,并且看起来不错。 I have 1 string and 2 objects in the API. 我在API中有1个字符串和2个对象。 I have a page that is calling in the full list of events using a page called event: 我有一个页面正在使用名为event的页面调用事件的完整列表:

{{ event.eventdescription }} {{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.

here is my event#show page. 这是我的活动#显示页面。 Very generic just trying to load any information at this point. 非常通用,只是在此时尝试加载任何信息。

<div ng-controller="ShowController">
  <super-navbar>
    <super-navbar-title>
      Show
    </super-navbar-title>
  </super-navbar>
<div class="padding">
  {{ event.eventdescription }}
</div>
</div>

And the showcontroller: 和showcontroller:

angular
  .module('event')
  .controller("ShowController", function ($scope, Event, supersonic) {
     $scope.events = null;


        Event.all().whenChanged( function (events) {
            $scope.$apply( function () {

            });
        });
      });

And this always returns a blank page. 并且这总是返回空白页。 When i check the log it says Undefined.undefined which i'm not sure what that means. 当我检查日志时,它显示Undefined.undefined,我不确定这是什么意思。

Any insight on this is greatly appreciated. 非常感谢对此有任何见识。 In the appgyver docs I saw something called. 在appgyver文档中,我看到了一个叫做的东西。

var view = new supersonic.ui.View("bananas#show");
                                    supersonic.ui.layers.push(view);

But I'm not sure how to use this? 但是我不确定该如何使用? ANY insight is appreciated. 任何见解都表示赞赏。

So, UPDATED I have: 因此,我有更新:

here's the event#index i'm working with. 这是我正在使用的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>

And the Index Controller 和索引控制器

 angular
  .module('event')
  .controller("IndexController", function ($scope, Event, supersonic) {
    $scope.events = null;

    Event.all().whenChanged( function (events) {
        $scope.$apply( function () {
          $scope.events = events;

        });
    });
  });

The show html page. 显示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 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;

  });
  });


  });

And I also updated the structure.coffee as so 我也更新了structure.coffee

 rootView:
    location: "event#index"

  preloads: [
  {
  id: "event#show"    
 }
 {
  id: "using-the-scanner"
  location: "example#using-the-scanner"
 }
 ]

Any help is appreciated. 任何帮助表示赞赏。

It doesn't look like the data is being set in the your ShowController. 看起来好像不是在ShowController中设置了数据。 I commented about this before. 我之前对此发表过评论。 I think you need to pass the id of the event using <super-navigate> with a location property and a data-params-id or whatever you want the parameter name to be. 我认为您需要使用带有location属性和data-params-id <super-navigate>传递事件data-params-id或任何您想要的参数名称。 Then in your ShowController you can access it with: 然后在ShowController中,您可以使用以下命令进行访问:

supersonic.ui.views.current.params.onValue( function (values) { 
    // values.nameOfPropertyPassedInCouldBeEventId
    $scope.id = values.id; 
});

Then you might be able to do something like this to access the Event by id: 然后,您可以执行以下操作以通过id访问事件:

Event.find($scope.id).then( function (theEvent) {
    $scope.$apply( function () {
      $scope.event = theEvent;
    });
  });

Now in your view where you have {{ event.eventdescription }} there should be some data. 现在,在您拥有{{ event.eventdescription }}视图中,应该有一些数据。

And another piece for when the view is visible meaning every time you see that view page this will fire: 还有另一个关于视图何时可见的含义,即每次您看到该视图页面时,都会触发:

supersonic.ui.views.current.whenVisible( function () { 
    // your code for watching events 
});

Ok, after a couple weeks of trying to get this working and although, I still haven't been able to get this to work yet.. I think I'm getting somewhere with this FINALLY... It seems the biggest problem here is using Kimono and AppGyver. 好吧,在尝试了几个星期之后,尽管如此,但我仍然无法使它开始运作。.我想我终于可以解决这个了……似乎最大的问题是使用和服和AppGyver。 The JSON file has been updated in Kimono using: JSON文件已在和服中使用以下方式更新:

function transform(data) {
  data.results.collection1 = data.results.collection1.map(function(o) {
    o.eventdescription = {
      text: o.eventdescription
    }
    return o;
  });
  return data;
}

This cleans up the JSON file exported/ coming in as API to App Gyver so that all parts are objects. 这将清除作为API向App Gyver导出/传入的JSON文件,以便所有部分都是对象。 ( I know, maybe not a big deal, but I just wanted to make this as clean as possible). (我知道,也许没什么大不了的,但是我只是想让它尽可能干净)。 To give you an idea of the before and after of using this script in the Kimono Modify Results box --> BEFORE: 为了让您了解在“和服修改结果”框中->之前使用此脚本的前后:

"EventTitles": {
"href": "http://",
"src": "http://.jpg",
"text": "Lorem Ipsum"
},
"HeadlineImages": {
"href": "http://",
"src": "http://.jpg",
"text": "Lorem Ipsum"
},
"eventdescription":"Lorem Ipsum" 
},

which leaves eventdescription as a string rather than object and then the AFTER: 它将eventdescription保留为字符串而不是对象,然后保留AFTER:

"EventTitles": {
"href": "http://",
"src": "http://.jpg",
"text": "TEXT"
},
"HeadlineImages": {
"href": "http://",
"src": "http://.jpg",
"text": "TEXT"
},
"eventdescription": {
"text": "TEXT"
}, 

So, after running this into Kimono as you can see all entries are "objects". 因此,将其运行到和服中后,您可以看到所有条目都是“对象”。 And you'd use &kimmodify=1 AFTER the apikey in the link thusly: 因此,您可以在链接中的apikey之后使用&kimmodify = 1:

https://www.kimonolabs.com/api/{indentifier}{apikey}&kimmodify=1

NEXT, as I was explained to by the AppGyver community one would pretty much need an "id" of sorts for each item in the JSON / API that's being created to be able to use the ShowController to create a reasonable/ feasible url string on the show.html. 下一步,正如我在AppGyver社区向我解释的那样,对于要创建的JSON / API中的每个项目,几乎都需要一个“ id”的种类,以便能够使用ShowController在上创建合理/可行的url字符串。 show.html。

Which should create something like /app/tier/showid=123456789 when going from the index to a specific entry view. 从索引转到特定的条目视图时,应该会创建类似/app/tier/showid=123456789

(You find the URLs by using the debug mode in AppGyver either via Safari Web Inspector on Mac with the IOS Emulator. or a browser using http://localhost:[some port number]/location/of/app when using the Android Emulator (the recommended Genymotion). (您可以使用Mac上的IOS Emulator在Mac上通过Safari Web Inspector在AppGyver中使用调试模式来找到URL。或者在使用Android Emulator时使用http://localhost:[some port number]/location/of/app的浏览器(推荐的Genymotion)。

So, to do this, in Kimono use the API Hash addition &kimhash=1 to the end of your url AFTER the APIKEY but BEFORE the modify such as this: 因此,要做到这一点,在和服中,请在APIKEY之后但在进行诸如此类的修改之前,在您的网址末尾使用API​​哈希添加&kimhash = 1

https://www.kimonolabs.com/api/{indentifier}{apikey}&kimhash=1&kimmodify=1

. See: Kimono API Docs- Re:Hash . 请参阅: 和服API文档-Re:Hash

This creates something like 这会产生类似

"EventTitles": {
"href": "http://",
"src": "http://.jpg",
"text": "TEXT"
},
"HeadlineImages": {
"href": "http://",
"src": "http://.jpg",
"text": "TEXT"
},
"eventdescription": {
"text": "TEXT"
}, 
"hash":"1a2b3c4d5e6f7g8h9z"},

a random 'indentifier' is created for each entry. 为每个条目创建一个随机的“标识符”。

Now, that's where I'm stuck now. 现在,这就是我现在停留的地方。 ...because the API URL needing to come in is: ...因为需要输入的API URL是:

https://www.kimonolabs.com/api/{indentifier}{apikey}&kimhash=1&kimmodify=1

and when you go to configure your API on the backend there is no area I see to enter this new &kimhash=1&kimmodify=1 that needs to be at the end of the URL to call in the correctly formatted and id'd API and as far as I can see there is no reference for doing this. 并且当您在后端上配置API时,我看不到要输入此新的&kimhash = 1&kimmodify = 1的区域,该区域必须位于URL的末尾才能调用格式正确且ID正确的API,如我所见,没有这样做的参考。

http://docs.appgyver.com/supersonic/guides/data/other-data-providers/kimono-labs/

I feel like this is the next to last step in figuring this all out and finally being able to get this up and working. 我觉得这是弄清所有内容并最终使它开始工作的最后一步。 The last being to obviously revisit pulling in the id to the ShowController which I'm feeling somewhat confident about if I can somehow figure out this last part. 最后一个显然是重新访问将ID拖入ShowController的过程,我对是否可以弄清楚这最后一部分感到有些自信。

Any ideas?? 有任何想法吗??

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM