-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathindex.html
219 lines (177 loc) · 7.89 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="UTF-8">
<title>angular-async-loader</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="assets/css/normalize.css" media="screen">
<link rel="stylesheet" type="text/css" href="assets/css/stylesheet.css" media="screen">
<link rel="stylesheet" type="text/css" href="assets/highlight.js/github.css">
<script src="assets/highlight.js/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head>
<body>
<section class="page-header">
<h1 class="project-name">angular-async-loader</h1>
<h2 class="project-tagline">An async loader for angular 1.x application</h2>
<a href="https://github.com/subchen/angular-async-loader" class="btn">View on GitHub</a>
<a href="https://github.com/subchen/angular-async-loader/zipball/master" class="btn">Download .zip</a>
<a href="https://github.com/subchen/angular-async-loader/tarball/master" class="btn">Download .tar.gz</a>
<a href="http://subchen.github.io/angular-async-loader/demo/" class="btn">Online Demo</a>
</section>
<section class="main-content">
<p>
<a href="https://www.npmjs.com/package/angular-async-loader"><img src="https://img.shields.io/npm/v/angular-async-loader.svg" alt="NPM Repo"></a>
<a href="http://www.apache.org/licenses/LICENSE-2.0"><img src="http://img.shields.io/badge/License-Apache_2-red.svg?style=flat" alt="License"></a>
</p>
<h1>angular-async-loader</h1>
<p>Load modules and components asynchronously for angular 1.x application.</p>
<p>Support load angular modules:</p>
<ul>
<li><code>app.useModule(name)</code></li>
</ul>
<p>Support load angular components:</p>
<ul>
<li><code>app.controller</code></li>
<li><code>app.services</code></li>
<li><code>app.filter</code></li>
<li><code>app.directive</code></li>
<li><code>app.value</code></li>
<li><code>app.constant</code></li>
<li><code>app.provider</code></li>
<li><code>app.decorator</code></li>
</ul>
<p>Support following amd/cmd loaders:</p>
<ul>
<li><code>Require.js</code></li>
<li><code>Sea.js</code></li>
<li><code>System.js</code></li>
</ul>
<p>Support <code>controllerUrl/denpendencies</code> config in <code>angular-ui-router</code> and <code>angular-route</code>:</p>
<ul>
<li><code>$stateProvider.state</code></li>
<li><code>$routeProvider.when</code></li>
</ul>
<h1>Demo</h1>
<p><a href="http://subchen.github.io/angular-async-loader/demo/">http://subchen.github.io/angular-async-loader/demo/</a></p>
<h1>Installation</h1>
<p>npm</p>
<div><pre><code class="bash">npm install angular-async-loader</code></pre></div>
<p>bower</p>
<div><pre><code class="bash">bower install https://github.com/subchen/angular-async-loader.git</code></pre></div>
<h1>Usage</h1>
<p><strong>index.html</strong></p>
<div><pre><code class="html"><script src="node_modules/requirejs/require.js"></script>
<script src="bootstrap.js"></script>
</code></pre></div>
<p><strong>bootstrap.js</strong></p>
<div><pre><code class="js">require.config({
baseUrl: '/',
paths: {
'angular': 'assets/angular/angular.min',
'angular-ui-router': 'assets/angular-ui-router/release/angular-ui-router.min',
'angular-async-loader': 'assets/angular-async-loader/angular-async-loader.min',
'angular-ui-mask': 'assets/angular-ui-mask/dist/mask.min',
'ng-tags-input': 'assets/ng-tags-input/build/ng-tags-input.min'
},
shim: {
'angular': {exports: 'angular'},
'angular-ui-router': {deps: ['angular']}
}
});
require(['angular', './app-routes'], function (angular) {
angular.element(document).ready(function () {
angular.bootstrap(document, ['app']);
angular.element(document).find('html').addClass('ng-app');
});
});</code></pre></div>
<p><strong>app.js</strong></p>
<div><pre><code class="js">define(function (require, exports, module) {
var angular = require('angular');
var asyncLoader = require('angular-async-loader');
require('angular-ui-router');
var app = angular.module('app', ['ui.router']);
// initialze app module for angular-async-loader
asyncLoader.configure(app);
module.exports = app;
});</code></pre></div>
<p><strong>app-routes.js</strong></p>
<div><pre><code class="js">define(function (require) {
var app = require('./app');
app.config(['$stateProvider', '$urlRouterProvider', function ($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/home');
$stateProvider
.state('home', {
url: '/home',
templateUrl: 'home/home.html',
// new attribute for ajax load controller
controllerUrl: 'home/homeCtrl',
controller: 'homeCtrl'
})
.state('users', {
url: '/users',
templateUrl: 'users/users.html',
// new attribute for ajax load controller
controllerUrl: 'users/usersCtrl',
controller: 'usersCtrl',
// support to load more controllers, services, filters, ...
dependencies: ['services/usersService']
})
.state('components', {
url: '/components',
templateUrl: 'components/components.html',
// new attribute for ajax load controller
controllerUrl: 'components/componentsCtrl',
controller: 'componentsCtrl'
});
}]);
});</code></pre></div>
<p><strong>users/usersCtrl.js</strong></p>
<div><pre><code class="js">define(function (require) {
var app = require('../app');
// dynamic load services here or add into dependencies of ui-router state config
// require('../services/usersService');
app.controller('usersCtrl', ['$scope', function ($scope) {
// shortcut to get angular injected service.
var userServices = app.get('usersService');
$scope.userList = usersService.list();
}]);
});</code></pre></div>
<p><strong>components/componentsCtrl.js</strong></p>
<div><pre><code class="js">define(function (require) {
var app = require('../app');
// dynamic load angular-ui-mask plugins for UI
require('angular-ui-mask');
app.useModule('ui.mask');
// dynamic load ng-tags-input plugins for UI
require('ng-tags-input');
app.useModule('ngTagsInput');
app.controller('componentsCtrl', ['$scope', function ($scope) {
......
}]);
});</code></pre></div>
<h1>Build from Source</h1>
<div class=""><pre><code class="bash">git clone https://github.com/subchen/angular-async-loader.git
cd angular-async-loader
./make.sh install
./make.sh test
open browser http://localhost:3000/
</code></pre></div>
<h1>License</h1>
<p>Released under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache 2 License</a>.</p>
<pre><code class="nohighlight">Copyright 2015-2016 Guoqiang Chen
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
</code></pre>
<footer class="site-footer">
<span class="site-footer-owner"><a href="https://github.com/subchen/angular-async-loader">angular-async-loader</a> is maintained by <a href="https://github.com/subchen">Guoqiang Chen</a>.</span>
</footer>
</section>
</body></html>