Putting it all together

We now have a full-fledged directive, and it's time to integrate it into our app. First, make sure that the new directive is properly loaded. The first line of the app.js file should look like this:

angular.module('supernav', ['ionic', 'supernav.controllers', 'supernav.directives'])

Likewise, the index.html file should contain the following import:

<script src="js/directives.js"></script>

Next, make sure that the ion-content section in index.html now looks like this:

<ion-content scroll="false">
  <map on-create="mapCreated(map)"></map>
</ion-content>

Next, since we moved the rendering logic for the map into the directive, remove it from the controller.js file, which should now look like this:

angular.module('supernav.controllers', ...

Get Learning Node.js for Mobile Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.