Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/463.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Ionic/Angular:使用主细节模式,细节页面为';你没来吗?_Javascript_Angularjs_Ionic Framework - Fatal编程技术网

Javascript Ionic/Angular:使用主细节模式,细节页面为';你没来吗?

Javascript Ionic/Angular:使用主细节模式,细节页面为';你没来吗?,javascript,angularjs,ionic-framework,Javascript,Angularjs,Ionic Framework,我的应用程序使用选项卡、侧菜单和主详细信息模式。但是,由于某种原因,当我尝试导航到列表中某个项目的详细信息页面时,什么也没有出现。我不确定我是不是走错路线了 如果有人能帮我,我会非常感激的!这快把我逼疯了 谢谢 app.js .config(function($stateProvider, $urlRouterProvider) { $stateProvider .state('tabs', { url: '/tab', controller: 'TabsC

我的应用程序使用选项卡、侧菜单和主详细信息模式。但是,由于某种原因,当我尝试导航到列表中某个项目的详细信息页面时,什么也没有出现。我不确定我是不是走错路线了

如果有人能帮我,我会非常感激的!这快把我逼疯了

谢谢

app.js

.config(function($stateProvider, $urlRouterProvider) {
  $stateProvider

    .state('tabs', {
      url: '/tab',
      controller: 'TabsCtrl',
      templateUrl: 'templates/tabs.html'
    })
    .state('tabs.feed', {
      url: '/feed',
      views: {
        'tab-feed': {
          templateUrl: 'templates/tab-feed.html',
          controller: 'FeedCtrl'
        }
      }
    })  

    .state('event-detail', {
      url: '/event-detail/:name',
      templateUrl: 'templates/event-detail.html',
      controller: 'EventDetailCtrl'
    })
tab feed.html

<ion-view view-title="Feed" class="tab-feed">
  <ion-nav-buttons side="right">
    <button class="button icon ion-funnel" ng-click="modal2.show()">
    </button>
  </ion-nav-buttons>
  <ion-nav-buttons side="left">
    <button class="button button-icon button-clear ion-navicon" ng-click="openMenu()"></button>
  </ion-nav-buttons>  
  <ion-content>
    <label class="item item-input">
    <i class="icon ion-search placeholder-icon"></i>
    <input type="search" placeholder="Search" ng-model="search">
  </label>
    <ion-list>
      <ion-item class="item item-thumbnail-left" ng-repeat="event in events | orderBy:'name' | searchEvents:search" type="item-text-wrap" href="#/event-detail/{{event.name}}">
          <img ng-src="http://placehold.it/300x300">
          <h2>{{event.name}}</h2>
          <p><i class="ion-clock"></i> {{event.date | date: 'MM/dd/yy'}} | {{event.time | date: 'shortTime'}}</p>
          <p><i class="ion-location"></i> {{event.location}}</p>
      </ion-item>

    </ion-list>
  </ion-content>

  <ion-footer-bar align-title="center" class="bar-positive">
      <div class="title" ng-click="modal.show()">Add Event</div>
  </ion-footer-bar>
</ion-view>
getLocalStorage服务

.factory('getLocalStorage', function () {

    var eventList = [];

    return {
            list: eventList,

        updateEvents: function (eventsArr) {
            if (window.localStorage && eventsArr) {
                localStorage.setItem("events", angular.toJson(eventsArr));
            }
            //update the cached version
            eventList = eventsArr;
        },

        getEvents: function () {
            eventList = angular.fromJson( localStorage.getItem("events") );
            return eventList ? eventList : [];
        },

        getEvent: function(name){
            for(i=0;i<eventList.length;i++){
                if(eventList[i].name == name){
                    return eventList[i];
                }
            }
          }
    };
})
.factory('getLocalStorage',函数(){
var eventList=[];
返回{
列表:事件列表,
updateEvents:函数(eventsArr){
if(window.localStorage&&eventsArr){
setItem(“events”,angular.toJson(eventsArr));
}
//更新缓存的版本
eventList=eventsArr;
},
getEvents:函数(){
eventList=angular.fromJson(localStorage.getItem(“事件”));
返回事件列表?事件列表:[];
},
getEvent:函数(名称){

对于(i=0;i您可以尝试以下方法:

1) 将
abstract:true
添加到
选项卡中
状态:

.state('tabs', {
    url: '/tab',
    controller: 'TabsCtrl',
    abstract: true,
    templateUrl: 'templates/tabs.html'
})
2) 在您的
EventDetailsCtrl
中,如果您正在考虑缩小,请按顺序在
函数之前添加所有注入参数…
如下:

.controller('EventDetailCtrl', ['$scope', 'getLocalStorage', '$stateParams', '$ionicSideMenuDelegate', function($scope, getLocalStorage, $stateParams, $ionicSideMenuDelegate) {

如果上述情况没有帮助,请发布您的
tabs.html
代码。

使用Chrome进行检查,并发送错误?这可能会导致错误,帮助我们确定根本原因。您的工厂在传递到控制器之前是否已初始化?它现在似乎正在工作!添加抽象:为tabs设置true会使所有内容都被禁用因为某种原因…但是,你的第二个建议似乎让一切都运转起来了!
.controller('EventDetailCtrl', ['$scope', 'getLocalStorage', '$stateParams', '$ionicSideMenuDelegate', function($scope, getLocalStorage, $stateParams, $ionicSideMenuDelegate) {