"var app = " always missing at top of app.js in example apps. why?

Hi!

I’m confused because in a lot of the examples (take this one for example: http://learn.ionicframework.com/formulas/navigation-and-routing-part-1/), the app.js file starts out with something along the lines of

var app = angular.module('ionicApp', ['ionic'])

the lines that follow are something along the lines of

app.config(function(){}) 

or

app.controller(function(){})

however

in the ionic templates (blank, tab, etc). the app.js file looks like this:

angular.module('starter', ['ionic'])

where did the var app = go? And why are subsequent controllers etc .controller instead of app.controller ?

Thank you!

@flomerboy just a preference. Since angular is a global object you can define your module with the ngular variable and chain controllers/config/run/service etc…

Not really an ionic thing but just an angular thing. The only issue with defining a module as a variable is unless you are wrapping your code around a self executing anonymous function, the app var will be on the global scope, which could potentially conflict with some other library that may decide to have a var with the same name. Therefore it’s recommended that you define your modules by chaining

check this out for more detailed explanation http://stackoverflow.com/questions/19957280/angularjs-best-practices-for-module-declaration