I would like to know how to code by feature in an Ionic application (and this point should be widened out to all Single Page Applications).
If I have an index.html that looks like this:
<!DOCTYPE html>
<html ng-app="ionicApp">
<head>
....
</head>
<body>
<ion-nav-bar class="bar-positive">
</ion-nav-bar>
<ion-tabs class="tabs-positive" animation="slide-left-right">
<ion-tab icon="ion-home" ui-sref="home">
<ion-nav-view name="home-tab"></ion-nav-view>
</ion-tab>
<ion-tab icon="ion-android-search" ui-sref="some-tab">
<ion-nav-view name="some-tab" ></ion-nav-view>
</ion-tab>
<ion-tab icon="ion-android-settings" ui-sref="settings">
<ion-nav-view name="settings-tab" ></ion-nav-view>
</ion-tab>
</ion-tabs>
</body>
</html>
And an app.js file that looks like this:
var app = angular.module('ionicApp', ['ionic', 'ratings']);
app.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/')
$stateProvider
.state('default', {
url: "/",
views: {
'home-tab': {
templateUrl: "templates/home.html",
controller: 'HomeTabCtrl'
}
}
})
...
});
});
How can I load different modules that perform different tasks? If this were a situation where different html pages were being loaded (standard web app), I could change the module reference at the top of the page. But with an SPA it loads the same index.html file everytime.
So, what do we do to achieve modularised code in Ionic?