首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >角度2的材质组件

角度2的材质组件
EN

Stack Overflow用户
提问于 2017-05-02 21:44:49
回答 2查看 392关注 0票数 0

我尝试在Github上只包含material-components repo中的snackbar组件:

https://github.com/material-components/material-components-web

EN

回答 2

Stack Overflow用户

发布于 2017-05-02 22:39:38

你可以试试https://material.angular.io

HTML

代码语言:javascript
复制
<button md-button (click)="openSnackBar()" aria-label="Show an example snack-bar">
  Pizza party
</button>

TS

代码语言:javascript
复制
import {Component} from '@angular/core';
import {MdSnackBar} from '@angular/material';


@Component({
  selector: 'snack-bar-component-example',
  templateUrl: './snack-bar-component-example.html',
})
export class SnackBarComponentExample {
constructor(public snackBar: MdSnackBar) {}

openSnackBar() {
 this.snackBar.openFromComponent(PizzaPartyComponent, {
   duration: 500,
  });
}
 }


@Component({
selector: 'snack-bar-component-example-snack',
templateUrl: './snack-bar-component-example-snack.html',
styleUrls: ['./snack-bar-component-example-snack.css'],
})
 export class PizzaPartyComponent {}

来自实际文档https://material.angular.io/components/component/snack-bar的示例

票数 1
EN

Stack Overflow用户

发布于 2017-11-19 04:05:19

Blox Material库提供了Web和Angular材质组件之间的集成。它还具有您想要使用的material-components snackbar组件的绑定。

这里有该库的入门指南:https://blox.src.zone/material#/guides/gettingstarted

snackbar消息的文档和代码示例可在此处找到:https://blox.src.zone/material#/directives/snackbar

简而言之,您必须安装@blox/material库并将其MaterialModule导入到您的Angular应用程序中。这将注册一个可用于创建snackbar消息的MdcSnackBarServicemdc-snackbar的所有选项、设置和主题功能都可用。

如果您遵循入门指南并且只使用MdcSnackBarService,那么您的产品构建将只包含snackbar组件的代码。

如果你想在没有现有集成库的情况下做到这一点,也许可以看看Blox材料中的源码以获得灵感。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43739530

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档