mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
feat($ionicConfigProvider): add $ionicConfigProvider
This commit is contained in:
@@ -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
52
js/angular/service/ionicConfig.js
vendored
Normal 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;
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user