У меня возникли трудности с тем, чтобы моя маршрутизация Angular работала в моем мобильном приложении (во время работы в консоли не появляются ошибки). Вот индекс. html файл (с div и ng-view)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title>index</title>
<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
<link href="css/ionic.app.css" rel="stylesheet">
-->
<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>
<script src="lib/bower_components/angular-route/angular-route.js"></script>
<script>
console.log("Setting jQuery from WL");
window.$ = window.jQuery = WLJQ; </script>
<!-- your app's js -->
<script src="app.js"></script>
</head>
<body>
<!-- SchedTek Header Bar -->
<ion-header-bar class="bar bar-header bar-calm">
<h1 class="title">SchedTekT</h1>
</ion-header-bar>
<!-- Content box to inject HTML pages -->
<div ng-view>
</div>
<!-- Footer tab menu -->
<div class="tabs tabs-icon-top">
<a class="tab-item" ng-href="#calendar" id="calendarTab">
My Calendar
</a>
<a class="tab-item" ng-href="#group" id="groupTab">
My Groups
</a>
<a class="tab-item tab-item-active" ng-href=#events id="eventTab">
My Events
</a>
<a class="tab-item" ng-href="#settings" id="settingsTab">
Settings
</a>
</div>
<script src="js/wlInit.js"></script>
</body>
</html>
Теперь кнопки вкладок с ng-href правильно меняют URL-адрес, но маршрут в app.js работает неправильно. Вот приложение.js
// Ionic Starter App
// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
var App = angular.module('App', ['ionic', 'ngRoute']);
App.config(['$routeProvider',
function($routeProvider)
{
$routeProvider
//route to account page
.when('/account',
{
templateURL:'pages/account.html',
controller: 'accountController'
})
//route to events page
.when('/events',
{
templateURL: 'pages/main.html',
controller: 'mainController'
})
//route to calendar page
.when('/calendar',
{
templateURL: 'pages/calendar.html',
controller: 'calendarController'
})
//route to group page
.when('/group',
{
templateURL: '/pages/group.html',
controller: 'groupController'
})
//route to specific group info
.when('/group/:groupName',
{
templateURL:'pages/groupoverview.html',
controller: 'groupIdController'
})
//route to settings page
.when('/settings',
{
templateURL:'pages/settings.html'
})
//default to events
.otherwise({
templateURL: 'pages/events.html',
controller: 'mainController'
});
}
]);
App.controller('mainController', function($scope){
$scope.message = 'main controller stuffs';
});
App.controller('accountController', function($scope){
$scope.message = 'account controller stuffs';
});
App.controller('calendarController', function($scope){
$scope.message = 'calendar controller stuffs';
});
App.controller('groupController', function($scope){
$scope.message = 'group controller stuffs';
});
App.controller('groupIdController', function($scope){
$scope.message = 'specific group controller stuffs';
});
например, страница groups.html выглядит так
<h1> Placeholder for group </h1>
<p>{{message}}</p>
и при нажатии на вкладку генерируется URL-адрес (в режиме предварительного просмотра браузера) идет от
(имя хоста):SchedTek/apps/services/preview/SchedTek/common/1.0/default/index.html
to
(HostName):SchedTek/apps/services/preview/SchedTek/common/1.0/default/index.html#/calendar, но ни один из шаблонов group.HTML не был введен в div в index.html
и просто чтобы вы могли получить общее представление о макете папки, картинка макета папки
Любая помощь будет принята с благодарностью. Я пробовал разные комбинации добавления «/» к путям шаблонов, перемещения по тегам и т. д.
Спасибо!
ng-include
вместо использования маршрутов? Концептуально вкладки используются для загрузки контента в представление, а не для изменения маршрутов в приложении. - person markyph   schedule 18.10.2015