Monaca Onsen UI Discord Chat Github Repo

Why ons.ready is always executed twice?



  • index.html

    <!DOCTYPE html>
    <html lang="en" ng-csp>
    <head>
        <title>xxxxxxxxxxxxxx</title>
        <meta http-equiv="Content-type" content="text/html; charset=utf-8">
        <meta http-equiv="Content-Security-Policy">
    
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
        <style>
            @-ms-viewport { width: 100vw ; zoom: 100% ; }  @viewport { width: 100vw ; zoom: 100% ; }
            @-ms-viewport { user-zoom: fixed ; }           @viewport { user-zoom: fixed ; }
        </style>  
    
        <link rel="stylesheet" href="lib/onsen/css/onsenui.min.css" />
    	<link rel="stylesheet" href="lib/onsen/css/onsen-css-components.min.css" />
    
        <link rel="stylesheet" href="lib/onsen/js/angular/angular-csp.css" />
    
        <script src="lib/onsen/js/angular/angular.min.js"></script>
    	<script src="lib/angular-sanitize/angular-sanitize.min.js"></script>
    	<script src="lib/onsen/js/onsenui.min.js"></script>
    	<script src="lib/onsen/js/angular-onsenui.min.js"></script>
    
    	<script src="cordova.js"></script>
    	<script src="js/app.js"></script>
    </head>
    
    <body>    
    <div ng-controller="PruebaController">
    ...
    ....
    ...
    </div> 
    </body>
    </html>
    

    app.js

    var myApp = ons.bootstrap('app', ['onsen', "ngSanitize"]);
    myApp.controller('PruebaController', function($scope, $filter, $sce, $http, $q, $interval, $location, $anchorScroll) {
    ...
    ...
    ons.ready(function() {
    ...
    ...
    }
    ...
    }
    

    Why ons.ready is always executed twice?

    Thanks in advance


  • Onsen UI

    @arcadio Can you make sure your controller is not running twice?



  • Thank you
    I was running twice the controller