feat($ionicConfigProvider): add $ionicConfigProvider

This commit is contained in:
Andrew
2014-08-13 11:34:03 -06:00
parent 8c6d5f2c96
commit 2643cffc19
2 changed files with 58 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
<!-- Action Sheet -->
<li class="menu-section">
<a href="{{ page.versionHref }}/api/service/$ionicActionSheet/" class="api-section">
@@ -551,6 +552,11 @@
Utility
</a>
<ul>
<li>
<a href="{{ page.versionHref }}/api/provider/$ionicConfigProvider/">
$ionicConfigProvider
</a>
</li>
<li>
<a href="{{ page.versionHref }}/api/utility/ionic.Platform/">
ionic.Platform

52
js/angular/service/ionicConfig.js vendored Normal file
View File

@@ -0,0 +1,52 @@
/**
* @ngdoc provider
* @name $ionicConfigProvider
* @module ionic
* @description $ionicConfigProvider can be used during the configuration phase of your app
* to change how Ionic works.
*
* @usage
* ```js
* var myApp = angular.module('reallyCoolApp', ['ionic']);
*
* myApp.config(function($ionicConfigProvider) {
* $ionicConfigProvider.prefetchTemplates(false);
* });
* ```
*/
IonicModule
.provider('$ionicConfig', function() {
var provider = this;
var config = {
prefetchTemplates: true
};
/**
* @ngdoc method
* @name $ionicConfigProvider#prefetchTemplates
* @description Set whether Ionic should prefetch all templateUrls defined in
* $stateProvider.state. Default true. If set to false, the user will have to wait
* for a template to be fetched the first time he/she is going to a a new page.
* @param shouldPrefetch Whether Ionic should prefetch templateUrls defined in
* `$stateProvider.state()`. Default true.
* @returns {boolean} Whether Ionic will prefetch templateUrls defined in $stateProvider.state.
*/
this.prefetchTemplates = function(newValue) {
if (arguments.length) {
config.prefetchTemlates = newValue;
}
return config.prefetchTemlates;
};
// private: Service definition for internal Ionic use
/**
* @ngdoc service
* @name $ionicConfig
* @module ionic
* @private
*/
this.$get = function() {
return config;
};
});