我想在angular2中使用颜色选择器。我尝试使用npm angular2-color-picker库。但是在包含该指令后我只能看到一个空白屏幕。 (在控制台中找不到错误)。请通过了解我出错的地方帮助我,或者让我知道是否还有其他angular2库可用于采摘颜色。提前谢谢。
我的HTML包括:
<div>
<label>Primary</label>
<input [(colorPicker)]="color" [style.background]="color" [value]="color"/>
</div>
我的TS :( AppComponent页面路由到DesignPage)
import {Component, OnInit} from 'angular2/core';
import {ColorPickerDirective} from 'angular2-color-picker/app/color-picker/color-picker.directive';
@Component({
selector: 'my-design',
templateUrl: 'wwwWeb/build/component/design/design.html',
directives: [ColorPickerDirective]
})
export class DesignPage implements OnInit {
private color: string = "#127bdc";
}
我的Boot.ts
import {bootstrap} from 'angular2/platform/browser';
import {AppComponent} from './app.component';
import {ColorPickerService} from './color-picker/color-picker.service'
bootstrap(AppComponent, [ColorPickerService]);
我的Tsconfig
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": [
"../node_modules",
"typings/main",
"typings/main.d.ts"
]
}
答案 0 :(得分:0)
您需要以这种方式配置库:
System.config({
map: {
'angular2-color-picker': 'node_modules/angular2-color-picker'
},
packages: {
(...)
'angular2-color-picker': {
format: 'register',
defaultExtension: 'js'
}
}
});