2017-12-20 5 views
0

私は角度のあるplnkrをセットアップしようとしています。デモでng-selectizeをインストールして設定する必要があります。私のplnkrにnpmパッケージng-selectizeを追加するにはどうすればいいですか?npmパッケージ(ng-selectize)をプランナー角度デモに追加して設定するにはどうすればよいですか?

http://plnkr.co/edit/msFyhztaC0YP1q6wADKq

import {Component, NgModule, VERSION} from '@angular/core' 
import {BrowserModule} from '@angular/platform-browser' 
import { NgSelectizeModule } from 'ng-selectize'; 

@Component({ 
    selector: 'my-app', 
    template: ` 
    <div> 
     <h2>Hello {{name}}</h2> 
     <ng-selectize [config]="config" [optgroups]="optgroups" [options]="options"></ng-selectize> 
    </div> 
    `, 
}) 
export class App { 
    name:string; 
    config = { 
     highlight: false, 
     create: false, 
     persist: true, 
     plugins: ['dropdown_direction', 'remove_button'], 
     dropdownDirection: 'down', 
     optgroupField: 'group', // Name of the property to group items by. 
     optgroupLabelField: 'label', // Name of the property to render as an option group label. 
     labelField: 'label', 
     valueField: 'value', 
     maxItems: 1000 
    } 

    optgroups = [ 
    { 
     group: 'colors', 
     label: 'colors' 
    }, 
    { 
     group: 'animals', 
     label: 'animals' 
    } 
    ]; 

    options = [ 
    { 
     label: 'Red', 
     value: 'red', 
     group: 'colors' 
    }, { 
     label: 'Blue', 
     value: 'blue', 
     group: 'colors' 
    }, { 
     label: 'Green', 
     value: 'green', 
     group: 'colors' 
    }, { 
     label: 'Dog', 
     value: 'dog', 
     group: 'animals' 
    } 
    ]; 
    constructor() { 
    this.name = `Angular! v${VERSION.full}` 
    } 
} 

@NgModule({ 
    imports: [ BrowserModule, NgSelectizeModule ], 
    declarations: [ App ], 
    bootstrap: [ App ] 
}) 
export class AppModule {} 

私はconfig.jsのにそれを追加すると、別のstackoverflowの答えは続くが、私は、エラーが見つかりませんlodash clonedeepを取得しています。 //:SystemJs httpsでライブラリを使用して、いくつかの合併症があるように見えます

+0

github.com/NicholasAzar/ng-selectize/issues/28 – JayChase

+0

角度や反応のために、これはplunkrとjsfiddleを殺します... https://stackblitz.com/ – FRECIA

+0

私はstackblitzを試しましたが、スタイル「」で '.angular-cli.json'を更新すると問題があるようです。 ["styles.css"、 "../ node_modules/selectize/dist/css/selectize.css"と言っていますが、stackblitzを使ってパッケージをインストールしてもファイルが見つかりません。それは通常のnode_modulesパスを持っていますか? – MonkeyBonkey

答えて

0

config.jsの

map: { 
    ..., 
    'ng-selectize': 'npm:ng-selectize', 
    'lodash.clonedeep': 'npm:lodash.clonedeep' 
} 

index.htmlを

<link rel="stylesheet" href="https://unpkg.com/selectize/dist/css/selectize.css" /> 
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/css/selectize.bootstrap3.css" /> 
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script> 
<script src="https://unpkg.com/ng-selectize/selectize/selectize.standalone.js"></script> 

Plunker Example

関連する問題