Skip to content

Commit 26872f6

Browse files
committed
feat(ComponentUrlMapper): retrieve the base URL for components
1 parent 9250cd6 commit 26872f6

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import {Type, isPresent} from 'angular2/src/facade/lang';
2+
import {Map, MapWrapper} from 'angular2/src/facade/lang';
3+
4+
export class ComponentUrlMapper {
5+
// Returns the url to the component source file.
6+
// The returned url could be:
7+
// - an absolute URL,
8+
// - a URL relative to the application
9+
getUrl(component: Type): string {
10+
return './';
11+
}
12+
}
13+
14+
export class RuntimeComponentUrlMapper extends ComponentUrlMapper {
15+
_componentUrls: Map;
16+
17+
constructor() {
18+
super();
19+
this._componentUrls = MapWrapper.create();
20+
}
21+
22+
setComponentUrl(component: Type, url: string) {
23+
MapWrapper.set(this._componentUrls, component, url);
24+
}
25+
26+
getUrl(component: Type): string {
27+
var url = MapWrapper.get(this._componentUrls, component);
28+
if (isPresent(url)) return url;
29+
return super.getUrl(component);
30+
}
31+
}

0 commit comments

Comments
 (0)