迁移到NgModule后我收到此错误,错误没有太大帮助,请问有什么建议吗?
Error: Error: Unexpected value 'undefined' imported by the module 'AppModule'
at new BaseException (http://localhost:5555/node_modules/@angular/compiler/bundles/compiler.umd.js:5116:27)
at eval (http://localhost:5555/node_modules/@angular/compiler/bundles/compiler.umd.js:13231:35)
at Array.forEach (native)
at CompileMetadataResolver.getNgModuleMetadata (http://localhost:5555/node_modules/@angular/compiler/bundles/compiler.umd.js:13215:48)
at RuntimeCompiler._compileComponents (http://localhost:5555/node_modules/@angular/compiler/bundles/compiler.umd.js:15845:51)
at RuntimeCompiler._compileModuleAndComponents (http://localhost:5555/node_modules/@angular/compiler/bundles/compiler.umd.js:15769:41)
at RuntimeCompiler.compileModuleAsync (http://localhost:5555/node_modules/@angular/compiler/bundles/compiler.umd.js:15746:25)
at PlatformRef_._bootstrapModuleWithZone (http://localhost:5555/node_modules/@angular/core/bundles/core.umd.js:9991:29)
at PlatformRef_.bootstrapModule (http://localhost:5555/node_modules/@angular/core/bundles/core.umd.js:9984:25)
at Object.eval (http://localhost:5555/app/main.js:8:53)
Evaluating http://localhost:5555/app/main.js
Error loading http://localhost:5555/app/main.js "Report this error at https://github.com/mgechev/angular2-seed/issues"(anonymous function) @ contracts:142ZoneDelegate.invoke @ zone.js?1472711930202:332Zone.run @ zone.js?1472711930202:225(anonymous function) @ zone.js?1472711930202:586ZoneDelegate.invokeTask @ zone.js?1472711930202:365Zone.runTask @ zone.js?1472711930202:265drainMicroTaskQueue @ zone.js?1472711930202:491ZoneTask.invoke @ zone.js?1472711930202:435
Run Code Online (Sandbox Code Playgroud)
app.module.ts:
import { NgModule } from '@angular/core';
import { BrowserModule …Run Code Online (Sandbox Code Playgroud) 如何以编程方式获取APP_BASE_HREF?
我在app.module.ts中有这个(其中APP_BASE ='/'):
{
provide: APP_BASE_HREF,
useValue: '<%= APP_BASE %>'
},
Run Code Online (Sandbox Code Playgroud)
我尝试着:
import { APP_BASE_HREF } from '@angular/common';
...
console.debug(APP_BASE_HREF.toString());
Run Code Online (Sandbox Code Playgroud)
在控制台我得到:
Token appBaseHref
Run Code Online (Sandbox Code Playgroud)
我需要得到:
http://localhost:5555/
Run Code Online (Sandbox Code Playgroud) 我有一个"bootstrapModal"属性指令,它将bootstrap属性添加到host元素:
data-placement="top" data-toggle="modal" data-target="#DefaultModalWindow"
Run Code Online (Sandbox Code Playgroud)
HostBinding是否可以使用这样的属性?
<htmltag ... bootstrapModal placement="left">
Run Code Online (Sandbox Code Playgroud)
在指令中有类似的东西:
@HostBinding('attributes.data-placement') // <== this dont work
@Input() placement:string='top';
Run Code Online (Sandbox Code Playgroud)
所以结果应该是:
<htmltag ... data-placement="left" data-toggle="modal" data-target="#DefaultModalWindow">
Run Code Online (Sandbox Code Playgroud) angular ×3