diff --git a/modules/angular2_material/src/components/progress-linear/progress_linear.ts b/modules/angular2_material/src/components/progress-linear/progress_linear.ts
index 532e52b579..c858a6df34 100644
--- a/modules/angular2_material/src/components/progress-linear/progress_linear.ts
+++ b/modules/angular2_material/src/components/progress-linear/progress_linear.ts
@@ -15,7 +15,7 @@ import {Math} from 'angular2/src/facade/math';
}
})
@View({
- templateUrl: 'angular2_material/src/components/progress-linear/progress_linear.html',
+ templateUrl: 'package:angular2_material/src/components/progress-linear/progress_linear.html',
directives: []
})
export class MdProgressLinear {
diff --git a/modules/angular2_material/src/components/radio/radio_button.html b/modules/angular2_material/src/components/radio/radio_button.html
index f24d2f64f0..cfd0841b51 100644
--- a/modules/angular2_material/src/components/radio/radio_button.html
+++ b/modules/angular2_material/src/components/radio/radio_button.html
@@ -1,4 +1,4 @@
-
+
diff --git a/modules/angular2_material/src/components/radio/radio_button.ts b/modules/angular2_material/src/components/radio/radio_button.ts
index d3b31b571b..36c6a3e3d7 100644
--- a/modules/angular2_material/src/components/radio/radio_button.ts
+++ b/modules/angular2_material/src/components/radio/radio_button.ts
@@ -36,7 +36,7 @@ var _uniqueIdCounter: number = 0;
'[attr.aria-activedescendant]': 'activedescendant'
}
})
-@View({templateUrl: 'angular2_material/src/components/radio/radio_group.html'})
+@View({templateUrl: 'package:angular2_material/src/components/radio/radio_group.html'})
export class MdRadioGroup {
/** The selected value for the radio group. The value comes from the options. */
value: any;
@@ -190,7 +190,10 @@ export class MdRadioGroup {
'[attr.aria-disabled]': 'disabled'
}
})
-@View({templateUrl: 'angular2_material/src/components/radio/radio_button.html', directives: []})
+@View({
+ templateUrl: 'package:angular2_material/src/components/radio/radio_button.html',
+ directives: []
+})
export class MdRadioButton {
/** Whether this radio is checked. */
checked: boolean;
diff --git a/modules/angular2_material/src/components/radio/radio_group.html b/modules/angular2_material/src/components/radio/radio_group.html
index 6de1e2618a..c516b6a245 100644
--- a/modules/angular2_material/src/components/radio/radio_group.html
+++ b/modules/angular2_material/src/components/radio/radio_group.html
@@ -1,2 +1,2 @@
-
+
diff --git a/modules/angular2_material/src/components/switcher/switch.html b/modules/angular2_material/src/components/switcher/switch.html
index 1e1b3b63f4..ed7449f7d5 100644
--- a/modules/angular2_material/src/components/switcher/switch.html
+++ b/modules/angular2_material/src/components/switcher/switch.html
@@ -1,4 +1,4 @@
-
+
diff --git a/modules/angular2_material/src/components/switcher/switch.ts b/modules/angular2_material/src/components/switcher/switch.ts
index e190779fad..55177ba67b 100644
--- a/modules/angular2_material/src/components/switcher/switch.ts
+++ b/modules/angular2_material/src/components/switcher/switch.ts
@@ -16,7 +16,8 @@ import {NumberWrapper} from 'angular2/src/facade/lang';
'[attr.role]': '"checkbox"'
}
})
-@View({templateUrl: 'angular2_material/src/components/switcher/switch.html', directives: []})
+@View(
+ {templateUrl: 'package:angular2_material/src/components/switcher/switch.html', directives: []})
export class MdSwitch {
/** Whether this switch is checked. */
checked: boolean;
diff --git a/modules/examples/src/material/demo_common.dart b/modules/examples/src/material/demo_common.dart
new file mode 100644
index 0000000000..60a86325a2
--- /dev/null
+++ b/modules/examples/src/material/demo_common.dart
@@ -0,0 +1,23 @@
+library angular2_examples.material.demo_common;
+
+import 'package:angular2/src/dom/browser_adapter.dart';
+import 'package:angular2/src/services/url_resolver.dart';
+
+void commonDemoSetup() {
+ BrowserDomAdapter.makeCurrent();
+}
+
+class DemoUrlResolver extends UrlResolver {
+
+ @override
+ String resolve(String baseUrl, String url) {
+ const MATERIAL_PKG = 'package:angular2_material/';
+
+ // We run a proxy server in front of pub serve that prepends "example" to
+ // paths
+ if (url.startsWith(MATERIAL_PKG)) {
+ return '/examples/packages/angular2_material/' + url.substring(MATERIAL_PKG.length);
+ }
+ return super.resolve(baseUrl, url);
+ }
+}
diff --git a/modules/examples/src/material/demo_common.ts b/modules/examples/src/material/demo_common.ts
index 46a9c13faa..55ae50943a 100644
--- a/modules/examples/src/material/demo_common.ts
+++ b/modules/examples/src/material/demo_common.ts
@@ -18,67 +18,16 @@ export function commonDemoSetup(): void {
@Injectable()
export class DemoUrlResolver extends UrlResolver {
- static a;
-
- isInPubServe: boolean;
-
constructor() {
super();
- if (isBlank(DemoUrlResolver.a)) {
- DemoUrlResolver.a = DOM.createElement('a');
- }
- this.isInPubServe = _isInPubServe();
}
resolve(baseUrl: string, url: string): string {
- if (isBlank(baseUrl)) {
- DOM.resolveAndSetHref(DemoUrlResolver.a, url, null);
- return DOM.getHref(DemoUrlResolver.a);
- }
-
- if (isBlank(url) || url == '') {
- return baseUrl;
- }
-
- if (url[0] == '/') {
- return url;
- }
-
- var m = RegExpWrapper.firstMatch(_schemeRe, url);
-
- if (isPresent(m[1])) {
- return url;
- }
-
- if (StringWrapper.startsWith(url, './')) {
- return `${baseUrl}/${url}`;
- }
-
- // Whether the `examples/` dir is being directly served (as the server root).
- // For cases when this is not true AND we're in pub-serve, `examples/` needs to be
- // prepended to the URL.
- var isDirectlyServingExamplesDir = !StringWrapper.contains(baseUrl, 'examples/');
-
- if (this.isInPubServe && isDirectlyServingExamplesDir) {
- return `/packages/${url}`;
- } else if (this.isInPubServe) {
- return `/examples/packages/${url}`;
- } else {
- return `/${url}`;
+ // The standard UrlResolver looks for "package:" templateUrls in
+ // node_modules, however in our repo we host material widgets at the root.
+ if (url.startsWith('package:angular2_material/')) {
+ return '/' + url.substring(8);
}
- }
-}
-
-var _schemeRe = /^([^:/?#]+:)?/g;
-
-// TODO: remove this hack when http://dartbug.com/23128 is fixed
-function _isInPubServe(): boolean {
- try {
- int.parse('123');
- print('>> Running in Dart');
- return true;
- } catch (_) {
- print('>> Running in JS');
- return false;
+ return super.resolve(baseUrl, url);
}
}
diff --git a/modules/examples/src/material/input/demo_app.html b/modules/examples/src/material/input/demo_app.html
index 2265147161..4f726c6692 100644
--- a/modules/examples/src/material/input/demo_app.html
+++ b/modules/examples/src/material/input/demo_app.html
@@ -1,4 +1,4 @@
-
+