使用cordova插件后,routeProvider不会一直执行

时间:2015-11-30 04:54:10

标签: angularjs cordova

这是我的index.html

<!DOCTYPE html>
<!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
-->
<html ng-app='pod'>
    <head>
        <!--
        Customize this policy to fit your own app's needs. For more guidance, see:
            https://github.com/apache/cordova-plugin-whitelist/blob/master/README.md#content-security-policy
        Some notes:
            * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
            * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
            * Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
                * Enable inline JS: add 'unsafe-inline' to default-src
        -->
        <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
        <meta name="format-detection" content="telephone=no">
        <meta name="msapplication-tap-highlight" content="no">
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">

        <link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.min.css" />
       <!--  <link rel="stylesheet" type="text/css" href="css/index.css"

       > -->
       <link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css" />
          <link rel="stylesheet" type="text/css" href="css/test.css">
          <script type="text/javascript" src="cordova.js"></script>
        <script type="text/javascript" src="js/index.js"></script>
        <script type="text/javascript" src="js/lib/angular.min.js"></script>
        <script type="text/javascript" src="js/lib/angular-route.min.js"></script> 
        <script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
        <script type="text/javascript" src="js/router.js"></script>  
         <!-- <script type="text/javascript" src="js/common/service.js"></script> --> 
        <script type="text/javascript" src="js/controller/LoginController.js"></script>
        <script type="text/javascript" src="js/controller/ScanMilkRunController.js"></script>
        <script type="text/javascript" src="js/controller/DealersListController.js"></script>
        <script type="text/javascript" src="js/controller/ScanDeliveryParcelController.js"></script>
        <script type="text/javascript" src="js/common/service.js"></script>
    </head>
    <body>
<!--
        <div class="app">
             MAIN CONTENT AND INJECTED VIEWS 
            <div id="main">
-->         <div class = "login">
                <div class="container-fluid">
                  <div class="row">
                    <div class="col-xs-12 col-md-12">
                      <div class="col-xs-4 col-md-8">
                        <img src="img/logo.jpg" class="img-logo">
                      </div>
                      <div class="col-xs-8 col-md-4">
                        <div class="login-header">
                          <h1 style="font-size:32px">CAT Group <br>Driver<br>Deliveries</h1>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
               </div> 
                <div ng-view></div>
<!--
            </div>
        </div>
-->

    </body>
</html>

这是我的路线提供者:

angular.module('pod', ['ngRoute'])
    .config(function($routeProvider) {
    // URL Routing Configuration
    alert('route');
    $routeProvider
        .when('/', {
            templateUrl : 'templates/Login.html',
            controller : 'LoginController'
        })
        .when('/dealersList', {
            templateUrl : 'templates/DealersList.html',
            controller : 'DealersListController'
        })
});

这是我的login.html

 <div class = "login">
      <div class="container-fluid">
        <div class="login-form">
          <h4>Driver Name</h4>
          <input type="text" ng-model="driverName" ng-bind="driverName"  placeholder="Driver Name">
           <h4>Password</h4>
          <input type="Password" ng-model="password" placeholder="Password">
          <!--       <input type="button" value="Reset" ng-click = "reset()"/>-->
          <div class="remember_me">
           <input type="checkbox" ng-model="chk" value="Remember Me">Remember Me</br>
         </div>
         <input type="button" value = "Login" ng-click = "Login()"/>
         <input type="button"  value = "Reset" ng-click = "reset()"/>
       </div>
     </div>
   </div>

这是我的loginController:

var app = angular.module('pod');
app.controller('LoginController', function($scope, $location, podService) {
    $scope.reset = function() {
       $scope.driverName = '';
       $scope.password = '';
    };
    $scope.Login = function(){
       if($scope.driverName == "" || $scope.driverName == null){
           //alert("Cie Name is required");
           navigator.notification.alert("Driver Name is required", loginAlertCallback, 'Alert', 'Ok');
       }
       else if($scope.password == "" || $scope.password == null){
           navigator.notification.alert("Password is required", loginAlertCallback, 'Alert', 'Ok');
       }else{
        podService.setDriverName($scope.driverName);
            $location.path('/scanMilkRun');
                cordova.plugins.barcodeScanner.scan(
            function (result) {
                $scope.milkRunCode = result.text;
                gatheringData();
            }, 
            function (error) {
                alert("Scanning failed: " + error);
            }
        );
        }
    };
    function gatheringData(){
        //          cordova.plugin.pDialog.init({progressStyle : 'HORIZONTAL', title: '', message : 'Gathering Data...'});
        //         cordova.plugin.pDialog.setProgress(90);   
        //          cordova.plugin.pDialog.setCancelable(false); 
        //          cordova.plugin.pDialog.dismiss();   
        // navigateDealersList();
         $location.path('/dealersList');

    }
    function navigateDealersList(){
        alert('4');


    }
});

因此,当点击登录按钮时,我将使用cordova中的插件和条形码成功功能调用条形码扫描器,我试图导航到另一种形式&#34; dealerlist&#34;使用&#34; $ location.path(&#39; / dealersList&#39;)&#34;但它并没有浏览经销商页面。

请帮助我解决问题

0 个答案:

没有答案