Cordova AngularJS如何从RAM中释放控制器?

时间:2017-07-28 08:21:15

标签: android html angularjs cordova

我正在7''上运行Cordova AngularJS App Android平板电脑。 该应用程序有三个控制器:RootController,TheatersController,SettingsController

pomidoroApp.config(function ($routeProvider) {
$routeProvider
    .when('/',
    {
        controller: 'RootController',
        templateUrl: 'views/RootControllerView.html'
    })
    .when('/theaters',
    {
        controller: 'TheatersController',
        templateUrl: 'views/TheatersControllerView.html'
    })
    .when('/settings',
    {
        controller: 'SettingsController',
        templateUrl: 'views/SettingsControllerView.html'
    })
    .otherwise({ redirectTo: '/'});

});

pomidoroApp.controller('RootController', function($scope,$window,$location){    
$scope.recommendedMovies = [];
init();
$scope.someFunction = function() {
     $location.path("/theaters");
            };
function init(){    
};  

});

pomidoroApp.controller('TheatersController', function($scope,theatersFactory,$window,$location){ 
$scope.theaters = [];
init();
$scope.someFunction2 = function() {
     $location.path("/");
           };   
function init(){
    $scope.theaters = theatersFactory.getTheaters();
}   

});

pomidoroApp.controller('SettingsController', function($scope){

});

RootControllerView.html:

<div class="content">
<ul class="list">
<button type="button" style="font-size:38px;" ng-click="someFunction()">Click Me!</button>
  <li class="list-divider">Recommended movies</li>
  <li ng-show="!ready">
    Receiving data...
  </li>
  <li ng-show="ready" ng-repeat="movie in recommendedMovies | filter:name">
    <a href="#/theaters">
      <div><img style="float:left; width:120px; height:177px; margin-right:10px;"class="movieimg" src="{{movie.posters.profile}}" /><strong style="font-size:18px;">{{movie.title}}</strong><p style="font-size:16px;">{{movie.critics_consensus}}</p></div>
      <div style="clear:both;"></div>   
    </a>
  </li>
</ul>

TheatersControllerView.html:

<div class="content">
<button type="button" style="font-size:38px;" ng-click="someFunction2()">Click Me 2!</button>
<ul class="list
  <li class="list-divider">Theaters nearby</li>
  <li data-ng-repeat="theater in theaters">
    <a href="#">
      <strong>{{theater.name}}</strong>
      <p>{{theater.address}}</p>
    </a>
  </li>
</ul>

在RootControllerView.html中,有一个按钮可以打开带有函数someFunction()的TheatersControllerView.html。 在TheatersControllerView.html中,有一个按钮可以打开带有函数someFunction2()的RootControllerView.html。 每次RootControllerView.html和TheatersControllerView.html都显示 someFunction()和someFunction2(),App使用的RAM正在增加。

App的名称是HelloCorodva,这是App的RAM使用情况: image of RAM usage of the App

如何降低App的RAM使用率? 如何释放RAM RootController或TheatresController?

0 个答案:

没有答案