Phonegap アプリケーションで Angulars ngRoute を使用してルーティングの問題を解決した人はいますか? 私はまだそれを理解していません... さまざまな魂を試してみましたが、誰もうまくいきません。こちらが最新です。助言がありますか?他にナビゲートするためのより良い方法はありますか、それとも jQuery を含めてまったく別のソリューションを作成する必要がありますか?
索引.html
<!DOCTYPE html>
<html>
<head ng-app="myApp">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<link href="lib/angular-mobile-ui/dist/css/mobile-angular-ui-base.min.css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<title>Test</title>
</head>
<body ng-controller="MainCtrl">
<div ng-view=""></div>
<script type="text/javascript" src="cordova.js"></script>
<script src="lib/angular-mobile-ui/dist/js/mobile-angular-ui.min.js"></script>
<script src="lib/angular/angular.js"></script>
<script src="lib/angular/angular-route.min.js"></script>
<script src="js/app.js"></script>
<script src="js/app/controllers/controllers.js"></script>
<script src="lib/phonegap.js"></script>
</body>
</html>
app.js
var myApp = angular.module("myApp", [ 'ngRoute','controllers', 'mobile-angular-ui', 'PhoneGap']);
myApp.config([$routeProvider,
function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: '/index.html',
controller: 'MainCtrl'
})
.when('/partials/intro', {
templateUrl: '/partials/intro.html',
controller: 'IntroCtrl',
template: '<h1> {{ test }} </h1>'
})
.when('/partials/about', {
templateUrl: '/partials/about.html',
controller: 'AboutCtrl'
})
.otherwise({
redirectTo: '/index'
});
}
]);
controllers.js
'use strict';
var myApp = angular.module('controllers', []);
myApp.controller("MainCtrl", function ($scope, $location, PhoneGap) {
});
//This is the controller that should be loaded in to the MainCtrl
myApp.controller("IntroCtrl", function ($scope, $location, PhoneGap) {
$scope.isAppLoaded = false;
// to detect if app is loaded
PhoneGap.ready().then(function () {
alert("App is loaded!");
$scope.isAppLoaded = true;
});
$scope.gotoIntro = function () {
$location.url('/intro');
};
});