伴随着 Angular 2 的正式 release,Kendo UI for Angular 2 的第一批控件已经发布了,当前是 Beta 版本,免费使用。

官方站点:Kendo UI for Angular 2 

Kendo UI for Angular 被打包成独立的多个 NPM package,在 Progress NPM 之下 ( https://registry.npm.telerik.com/ ), 要想访问它,你需要一个激活的 Telerik account , 如果你现在还没有这个账号,可以到这里创建一个,这是免费的。这些包在 @progress 之下。例如,Grid 控件包的名字是 @progress/kendo-angular-grid.

安装

为了在你的机器上启用 Progress registry,你应该关联 @progress 到 registry URL 上,在命令行终端中,执行下面的命令。

npm login --registry=https://registry.npm.telerik.com/ --scope=@progress

NPM 将会询问你的 Telerik 账号和邮件,在 Username 中输入你的用户名 (如果你的用户名是一个邮件地址,仅仅输入 @ 之前的部分),Password 就是你的 Telerik 账号口令。

验证

如果上面的命令成功执行了,你应该可以安装 Kendo UI 的 NPM Package 了,可以先查询一下 Grid  控件的版本进行检查。

npm view @progress/kendo-angular-grid versions

输出结果应该类似下面的输出。

>npm view @progress/kendo-angular-grid versions
[ '0.2.1', '0.2.2', '0.3.0', '0.3.1' ]

将组件添加到你的项目中

Kendo UI for Angular 2 的组件被组织为多个 NPM Package。它们的命名规则为 @progress/kendo-angular-grid@progress/kendo-angular-inputs 等等。我们先添加 Buttons 的组件包。

在你的项目根目录中,执行下面的命令

npm install -S @progress/kendo-angular-buttons

稍等一会,如果 NPM 正常完成了安装,这个包和它所依赖的包将会被安装到你的项目中。

然后,导入组件到你的项目中,假设你正在使用 Angular 2 官方提供的 5 分钟快速上手。如果你还没有这个项目,可以访问这里:https://github.com/telerik/kendo-angular2-quickstart

修改一下 app.module.ts 文件,如下所示。

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { ButtonsModule } from '@progress/kendo-angular-buttons'; import { AppComponent } from './app.component'; @NgModule({
imports: [ BrowserModule, ButtonsModule ],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }

然后,修改 app.component.ts,添加一个按钮。

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

@Component({
selector: 'my-app',
template: `
<h1>My First Kendo UI Angular 2 App</h1>
<button kendoButton (click)="onButtonClick()" [primary]=true>My Kendo UI Button</button>
`
})
export class AppComponent {
onButtonClick() {
alert('Hello from Kendo UI!');
}
}

添加样式

可以有多种方式将 Kendo UI 的 theme 包含到项目中,我们建议使用 Webpack 和 Sass loader,这种方式支持使用 Sass 变量来定制 Kendo Ui 的 theme。

这里,我们简单一点,直接在 Component 中使用 StyleUrls 来引入样式。

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

@Component({
selector: 'my-app',
styleUrls: [ '../node_modules/@progress/kendo-angular-buttons/dist/npm/css/main.css' ], // load the button theme
template: `<h1>My First Kendo UI Angular 2 App</h1>
<button
kendoButton
(click)="onButtonClick()"
[primary]=true
>My Kendo UI Button</button>
`, })
export class AppComponent {
onButtonClick() {
alert('Hello from Kendo UI!');
}
}

当样式到位之后,你的应用看起来应该如下所示了。

按钮被完全支持了,并且看起来很气派!

集成 Kendo UI for Angular 2 控件的更多相关文章

  1. Kendo UI for Angular 2 控件

    Kendo UI for Angular 2 控件 伴随着 Angular 2 的正式 release,Kendo UI for Angular 2 的第一批控件已经发布了,当前是 Beta 版本,免 ...

  2. iOS开发UI篇—手写控件,frame,center和bounds属性

    iOS开发UI基础—手写控件,frame,center和bounds属性 一.手写控件 1.手写控件的步骤 (1)使用相应的控件类创建控件对象 (2)设置该控件的各种属性 (3)添加控件到视图中 (4 ...

  3. iOS开发UI基础—手写控件,frame,center和bounds属性

    iOS开发UI基础—手写控件,frame,center和bounds属性 一.手写控件 1.手写控件的步骤 (1)使用相应的控件类创建控件对象 (2)设置该控件的各种属性 (3)添加控件到视图中 (4 ...

  4. Semantic UI中的验证控件的事件的使用

    1.Semantic UI中的验证控件,功能挺不错的,中文官网的文档写的都比较详细了,我再这里就不再进行重复了,主要是想说一下它的事件的使用方法,这个可能有部分朋友刚开始接触的时候不太了解 注意看这几 ...

  5. 使用 Microsoft.UI.Xaml 解决 UWP 控件和对老版本 Windows 10 的兼容性问题

    原文 使用 Microsoft.UI.Xaml 解决 UWP 控件和对老版本 Windows 10 的兼容性问题 虽然微软宣称 Windows 10 将是最后一个 Windows 版本,但由于年代跨越 ...

  6. Android UI组件----ListView列表控件详解

    [声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/3 ...

  7. C#用副线程改主线程(UI线程)的控件属性的方法(包括Winform和WPF)

    C#用副线程去试图修改主线程的UI控件会报出异常,解决方案是使用副线程注册事件通知主线程自己去修改UI控件 在winform中,方法如下 private void button1_Click(obje ...

  8. Qt中在UI文件中新建控件并命名,但在代码中无法识别UI中的控件?

    代码中添加FilePathLineEdit控件,显示标准文件选择对话框显示选择的文件路径,但在槽函数中ui->FilePathLineEdit->setText("FilePat ...

  9. js ui框架 My97日期控件 富文本编辑器

    My97日期控件 http://www.my97.net/dp/index.asp 富文本编辑器 http://www.kindsoft.net/demo.php 百度的magic也不错 http:/ ...

随机推荐

  1. 开启Java博客

    已经转Java大半年了,Java知识都来自于工作,没有一个系统的学习,所以这一个多月我都在看Java的一些基本东西,准备系统性的学习下Java知识.这一个多月看的也挺多,从servlet,jsp,st ...

  2. php 把数字1-1亿换成汉字表述,例如 150 转成 一百五十

    /* 额,重新修改了下.现在估计没什么问题了.... */ 直接上实例 写到 千亿上了. /** * @author ja颂 * 把数字1-1亿换成汉字表述,如:123->一百二十三 * @pa ...

  3. HDU 1010 Tempter of the Bone(深度+剪枝)

    http://acm.hdu.edu.cn/showproblem.php?pid=1010 题意:就是给出了一个迷宫,小狗必须经过指定的步数到达出口,并且每个格子只能走一次. 首先先来介绍一下奇偶性 ...

  4. 51nod 1228 序列求和 ( 1^k+2^k+3^k+...+n^k )

    C为组合数,B为伯努利数 具体推到过程略 参考博客:http://blog.csdn.net/acdreamers/article/details/38929067# (我的式子和博客中的不一样,不过 ...

  5. JS在路径中传中文参数

    需要用 encodeURI('中文');处理一下.

  6. IOS 关键字self,super,copy, retain, assign , readonly , readwrite, nonatomic、 @synthesize、@property、@dynamic

    IOS 关键字self,super,copy, retain, assign , readonly , readwrite, nonatomic.                     @synth ...

  7. Python>>>Flask框架使用之入门

    操作平台Windows Python2.7 安装 pip install flask Hello World程序 from flask import Flask app = Flask(__name_ ...

  8. 【转】libevent和基于libevent的网络编程

    转自: http://www.cnblogs.com/nearmeng/p/4043548.html 1 libevent介绍和安装 介绍 libevent是一个轻量级的基于事件驱动的高性能的开源网络 ...

  9. E 最熟悉的陌生人 (纪念当年就读的梅州市江南高级中学)

    最熟悉的陌生人 作者:张慧桥 枪与玫瑰” 负责审讯的兄弟真是好样的,回来后的第四天上午就让黄志深那小子招了出来. 这可真的不容易! 现在公安部对我们审讯工作有很多的规定,其中一条就是不准刑讯逼供,就是 ...

  10. My Open Source Projects

    • MyMagicBox (https://github.com/yaoyansi/mymagicbox)   Role: Creator   Miscellaneous projects for e ...