Cordova角度应用程序在几次重新启动后不会切换视图

时间:2015-09-03 07:11:41

标签: android angularjs cordova twitter-bootstrap-3

应用程序在首次启动时运行正常,我可以切换视图并显示ng-dialogues(我正在使用名为ui-views),

经过一两次暂停或重新启动后,它仍然可以正常响应,我仍然可以滚动并输入输入。

它拒绝切换到其他视图或显示ng-dialogue。强制停止应用后,这个问题就消失了。

我尝试将config.xml中的启动模式切换为singleInstancesingleTask但没有成功。问题也出现在release build

怀疑我的代码导致了这个因为它运行一次吗?有什么想法吗?

以下是角度路径主控制器和index.html的示例代码。

路线

(function() {
  "use strict";

  angular
    .module("cvideo")
    .config(routeConfig);

  /** @ngInject */
  function routeConfig($stateProvider, $urlRouterProvider) {
    $stateProvider
      .state("home", {
          url: "/",
          views: {
              nav: {
                  templateUrl: "app/components/navbar/navbar.html",
                  controller: "NavCtrl"
              },
              content: {
                  templateUrl: "app/main/main.html",
                  controller: "MainCtrl"
              }
          }
      })
          .state("jobs", {
              url: "/jobs",
              views: {
                  nav: {
                      templateUrl: "app/components/navbar/navbar.html",
                      controller: "NavCtrl"
                  },
                  content: {
                      templateUrl: "app/components/job/newJob.html",
                      controller: "JobCtrl"
                  }
              }
          });
    $urlRouterProvider.otherwise("/");
       }
  })();

的index.html

<body>
<div ui-view="nav"></div>
<div class="content" ui-view="content"></div>
</body>

MainCtrl

(function(){
    "use strict";

    angular.module("cvideo")
        .controller("MainCtrl", function ($scope, ngDialog) {
            $scope.jobs = [];


            for (var i = 1; i < 10; i++) {
                var job = {
                    title: "Job Offer " + Math.round(Math.random()*1000),
                    date: new Date(100*60 * 60 * 24 * 365*50*i),
                    description: "Job Offer "+i+" Description.",
                    qualification: "Job Offer " + i + " Required Qulifications.",
                    video: {
                        limit: i*10,
                        local: "",
                        web: ""
                    }
                };
                $scope.jobs.push(job);
            }

            $scope.preview = function (job) {
                $scope.job = job;
                ngDialog.open({
                    template: "app/components/job/job.html",
                    scope: $scope,
                    showClose:false
                });
            };

        });
})();

main.html中

<div class="jumbotron col-md-4" ng-repeat-start="job in jobs">
    <div class="container">
        <div class="row" ng-click="preview(job)">
                <h3 ng-bind="job.title"></h3>
                <label ng-bind="job.date|date:'Due MM/dd/yyyy'"></label>
                <p ng-bind="job.description.length>100?job.description.substr(0,97)+'...':job.description"></p>
            <div class="clearfix" ng-if="$index%3==2"></div>
        </div>
    </div>
</div>
<div ng-repeat-end=""></div>

0 个答案:

没有答案