aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ng/directive/ngView.js4
-rw-r--r--src/ng/route.js27
2 files changed, 19 insertions, 12 deletions
diff --git a/src/ng/directive/ngView.js b/src/ng/directive/ngView.js
index 1d2a5d29..28646822 100644
--- a/src/ng/directive/ngView.js
+++ b/src/ng/directive/ngView.js
@@ -49,11 +49,11 @@
<file name="script.js">
angular.module('ngView', [], function($routeProvider, $locationProvider) {
$routeProvider.when('/Book/:bookId', {
- template: 'book.html',
+ templateUrl: 'book.html',
controller: BookCntl
});
$routeProvider.when('/Book/:bookId/ch/:chapterId', {
- template: 'chapter.html',
+ templateUrl: 'chapter.html',
controller: ChapterCntl
});
diff --git a/src/ng/route.js b/src/ng/route.js
index ab198188..032e3716 100644
--- a/src/ng/route.js
+++ b/src/ng/route.js
@@ -29,9 +29,12 @@ function $RouteProvider(){
*
* - `controller` – `{function()=}` – Controller fn that should be associated with newly
* created scope.
- * - `template` – `{string=}` – path to an html template that should be used by
+ * - `template` – `{string=}` – html template as a string that should be used by
* {@link angular.module.ng.$compileProvider.directive.ngView ngView} or
* {@link angular.module.ng.$compileProvider.directive.ngInclude ngInclude} directives.
+ * this property takes precedence over `templateUrl`.
+ * - `templateUrl` – `{string=}` – path to an html template that should be used by
+ * {@link angular.module.ng.$compileProvider.directive.ngView ngView}.
* - `resolve` - `{Object.<string, function>=}` - An optional map of dependencies which should
* be injected into the controller. If any of these dependencies are promises, they will be
* resolved and converted to a value before the controller is instantiated and the
@@ -49,7 +52,7 @@ function $RouteProvider(){
* If `redirectTo` is a function, it will be called with the following parameters:
*
* - `{Object.<string>}` - route parameters extracted from the current
- * `$location.path()` by applying the current route template.
+ * `$location.path()` by applying the current route templateUrl.
* - `{string}` - current `$location.path()`
* - `{Object}` - current `$location.search()`
*
@@ -152,7 +155,7 @@ function $RouteProvider(){
<hr />
<pre>$location.path() = {{$location.path()}}</pre>
- <pre>$route.current.template = {{$route.current.template}}</pre>
+ <pre>$route.current.templateUrl = {{$route.current.templateUrl}}</pre>
<pre>$route.current.params = {{$route.current.params}}</pre>
<pre>$route.current.scope.name = {{$route.current.scope.name}}</pre>
<pre>$routeParams = {{$routeParams}}</pre>
@@ -173,7 +176,7 @@ function $RouteProvider(){
<file name="script.js">
angular.module('ngView', [], function($routeProvider, $locationProvider) {
$routeProvider.when('/Book/:bookId', {
- template: 'book.html',
+ templateUrl: 'book.html',
controller: BookCntl,
resolve: {
// I will cause a 1 second delay
@@ -185,7 +188,7 @@ function $RouteProvider(){
}
});
$routeProvider.when('/Book/:bookId/ch/:chapterId', {
- template: 'chapter.html',
+ templateUrl: 'chapter.html',
controller: ChapterCntl
});
@@ -365,17 +368,21 @@ function $RouteProvider(){
then(function() {
if (next) {
var keys = [],
- values = [];
+ values = [],
+ template;
forEach(next.resolve || {}, function(value, key) {
keys.push(key);
values.push(isFunction(value) ? $injector.invoke(value) : $injector.get(value));
});
- if (next.template) {
+ if (isDefined(template = next.template)) {
+ } else if (isDefined(template = next.templateUrl)) {
+ template = $http.get(template, {cache: $templateCache}).
+ then(function(response) { return response.data; });
+ }
+ if (isDefined(template)) {
keys.push('$template');
- values.push($http.
- get(next.template, {cache: $templateCache}).
- then(function(response) { return response.data; }));
+ values.push(template);
}
return $q.all(values).then(function(values) {
var locals = {};