I am new to ionic and have successfully installed and tested my first tutorial app. I am facing the following problem while working around with this tutorial http://ionicframework.com/docs/guide/building.html
When I create a blank project 'app.js' is created with the following code in it:
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs).
// The reason we default this to hidden is that native apps don't usually show an accessory bar, at
// least on iOS. It's a dead giveaway that an app is using a Web View. However, it's sometimes
// useful especially with forms, though we would prefer giving the user a little more room
// to interact with the app.
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
// Set the statusbar to use the default style, tweak this to
// remove the status bar on iOS or change it to use white instead of dark colors.
StatusBar.styleDefault();
}
});
});
However the following code won't work unless I remove the above js code. So my question: Is it important to keep the above code? or can I do away with it? If it's important how do I maintain both these codes.
.controller('TodoCtlr', function($scope){
$scope.tasks = [
{title: 'Collect Coins'},
{title: 'Read books'},
{title: 'Go home '},
{title: 'have dinner'}
];
});
Thanks for your time.
In ionic app.js is where all modules related to application are injected and also other app configuration.
the first code snippet is to check whether device is ready or not so i thnk you should put this.
as for the controller you can easily place this code in your controller.js file
just make sure these files are included in index.html
try reading and following ionic docs as those are great and nicely written. http://ionicframework.com/docs/
The code works if I remove the ;
from the last line of the run function code. This line is like the ending of the file, so if there is a controller after that it won't be recognized. It should look like this:
// run function stuff...
})
.controller('TodoCtlr', function($scope){
// your controller
}); // Here should be the end now!
Source: http://forum.ionicframework.com/t/importance-of-run-function-ionicplatform/17935/3
Courtesy: http://forum.ionicframework.com/users/saimon/activity