angular-cn/modules/@angular/examples/compiler/ts/url_resolver/url_resolver.ts

20 lines
557 B
TypeScript

import {provide} from '@angular/core';
import {bootstrap} from '@angular/platform-browser';
import {UrlResolver} from '@angular/compiler';
var MyApp: any;
// #docregion url_resolver
class MyUrlResolver extends UrlResolver {
resolve(baseUrl: string, url: string): string {
// Serve CSS files from a special CDN.
if (url.substr(-4) === '.css') {
return super.resolve('http://cdn.myapp.com/css/', url);
}
return super.resolve(baseUrl, url);
}
}
bootstrap(MyApp, [provide(UrlResolver, {useClass: MyUrlResolver})]);
// #enddocregion