从angularjs.TypeScript.DefinitelyTyped 2.1.6 升级到3.1.2删除了angular我用于模块声明文件的静态变量的可访问性.
以下现在会出现angular无法正确解析符号的错误.
angular
.module("someModule")....
Run Code Online (Sandbox Code Playgroud)
Resharper提供了从外部模块导入变量的选项,但这不起作用.
angular早期版本中全局变量的曝光是错误吗?是不打算以我的项目使用它的方式使用它?
我不明白为什么以下不起作用。如果我使用文字字符串来分配 APP_BASE_HREF 它工作正常。
主要.ts
export function main(baseHref: string) {
platformBrowserDynamic([
{ provide: MY_BASE_HREF, useValue: baseHref },
]).bootstrapModule(AppModule);
}
Run Code Online (Sandbox Code Playgroud)
应用程序模块.ts
export const MY_BASE_HREF = new InjectionToken<string>('BaseHref')
@NgModule({
...
providers: [{ provide: APP_BASE_HREF, useValue: MY_BASE_HREF }],
...
})
Run Code Online (Sandbox Code Playgroud)
这是控制台错误的重要部分
Unhandled Promise rejection: url.replace is not a function ; Zone: <root> ; Task: Promise.then ; Value: TypeError: url.replace is not a function
at _stripIndexHtml (node_modules/@angular/common/bundles/common.umd.js:439)
at new Location (node_modules/@angular/common/bundles/common.umd.js:278)
我可以不使用一个 InjectionToken 来定义另一个 InjectionToken 吗?