javascript - AppGyver Steroids 超音速 View

标签 javascript angularjs steroids appgyver supersonic

我正在尝试切换 View /将 View 传递到另一个 View 。

我有一个应用程序正在调用 kimono API,所有设置都带有超音速背景,看起来不错。我在 API 中有 1 个字符串和 2 个对象。我有一个页面使用名为 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.

这是我的事件#show 页面。非常通用,此时只是尝试加载任何信息。

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

和显示 Controller :

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


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

            });
        });
      });

这总是返回一个空白页。当我检查日志时,它显示 Undefined.undefine ,我不确定这是什么意思。

对此的任何见解都将受到高度赞赏。在 appgyver 文档中我看到了一个叫做的东西。

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>

和索引 Controller

 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>

显示 Controller

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"
 }
 ]

感谢任何帮助。

最佳答案

看起来数据并未在您的 ShowController 中设置。我之前评论过这个。我认为您需要使用 <super-navigate> 传递事件的 id与 location属性(property)和data-params-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 }}应该有一些数据。

当 View 可见时,另一部分意味着每次您看到该 View 页面时都会触发:

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

关于javascript - AppGyver Steroids 超音速 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29380008/

相关文章:

javascript - 金色布局 : how to increase Header Tabs height

javascript - Angularjs 使用外部变量验证字段更改的表单

javascript - 使用jquery设置输入元素的值

node.js - 为什么 npm 给出 500 和 503 错误 : "registry error parsing json"?

javascript - Angular - 使用函数对数字求和并将其放在 View 中

javascript - 如何在 Appgyver Steroids 应用程序中通过 Google 文档在 Android webview 中查看 PDF?

vbscript - Internet Explorer 获取内部 IP 地址

javascript - PHP和JS读取HTML5中的音频流是否中断

javascript - 全日历显示加号事件下的所有事件

javascript - AngularJs 中简单 if else if 循环的循环复杂度