簡體   English   中英

在Angular 2中添加jQuery-Knob

[英]Add jQuery-Knob in Angular 2

我是Angular 2.0的新手,並使用aspnetboilerplate模板。

我正在嘗試集成jQuery-Knob

首先,我包括jquery.knob.min.jsscripts.angular-cli.json

"scripts": 
[
    "../src/bsb-theme/js/jquery.validate.js",
    "../src/bsb-theme/js/jquery.knob.min.js"
]

然后,我在dashboard.component.html input了內容:

<input type="text" class="knob" value="40"
    data-width="125"
    data-height="125"
    data-thickness="0.25"
    data-angleArc="250"
    data-angleoffset="-35"
    data-fgColor="#00BCD4">

但是輸出僅是文本框。

jQuery-Knob無法與Angular 2配合使用。

試試這個庫: https : //github.com/xzegga/angular2-knob


用法

導入角模塊:

import { KnobModule } from "angular2-knob";

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [KnobModule]
  bootstrap: [AppComponent]
})

HTML使用:

<div ui-knob [value]="value" [options]="knOptions"></div>

在角組件中配置選項:

import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent{
  knOptions = {
    readOnly: true,
    size: 140,
    unit: '%',
    textColor: '#000000',
    fontSize: '32',
    fontWeigth: '700',
    fontFamily: 'Roboto',
    valueformat: 'percent',
    value: 0,
    max: 100
    trackWidth: 19,
    barWidth: 20,
    trackColor: '#D8D8D8',
    barColor: '#FF6F17',
    subText: {
      enabled: true,
      fontFamily: 'Verdana',
      font: '14',
      fontWeight: 'bold',
      text: 'Overall',
      color: '#000000',
      offset: 7
    },
  }
  value = 45; 
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM