[Angular 2] Style Angular 2 Components
Each Angular 2 Component can have its own styles which will remained contained inside the component. These isolated styles allow you to add whichever styles you want without worrying about them leaking out and affecting the rest of your application.
import {Component, Input} from "@angular/core";
@Component({
selector: 'widget-one',
styles:[`
:host{
display: block;
border: 3px dashed black;
font-family: "Times New Roman";
}
`],
template: `
<h2>One's message:</h2>
<h3>{{message}}</h3>
`
})
export class WidgetOne{
@Input() message;
}

Notice three things:
1. If you want to apply style to 'widget-one' tag, which means the host element for the component, you need to use ':host'.
2. The style apply only has affect to this component, won't have any effect to other component.
3. The host component doesn't have any 'display' attr setup, so you need to set it as 'flexbox' or 'block', or any other display prop....
[Angular 2] Style Angular 2 Components的更多相关文章
- Angular 2 to Angular 4 with Angular Material UI Components
Download Source - 955.2 KB Content Part 1: Angular2 Setup in Visual Studio 2017, Basic CRUD applicat ...
- 使用Angular CLI生成 Angular 5项目
如果您正在使用angular, 但是没有好好利用angular cli的话, 那么可以看看本文. Angular CLI 官网: https://github.com/angular/angular- ...
- Angular 1与 Angular 2之间的一些差别
现在在用ng1.5.8做一个项目,ng的优点和特性我就不用多说了,ng1在陆续更新到1.5/1.6后就没再推出新版本了,ng2已经面世测试很久了,如同很多系统和框架一样,每个大的版本更新都会有新特性加 ...
- AngularJs angular.injector、angular.module
angular.injector 创建一个injector对象, 调用injector对象的方法可用于获取服务以及依赖注入. 格式:angular.injector(modules); modules ...
- angular.js 的angular.copy 、 angular.extend 、 angular.merge
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- Angular - - angular.injector、angular.module
angular.injector 创建一个injector对象, 调用injector对象的方法可用于获取服务以及依赖注入. 格式:angular.injector(modules); modules ...
- Angular 学习笔记 (Angular 9 & ivy)
refer : https://blog.angularindepth.com/all-you-need-to-know-about-ivy-the-new-angular-engine-9cde47 ...
- Angular JS - 5 - Angular JS 模块和控制器
1.引入 1.5版本的angularjs,直接打印angular对象: --> <!DOCTYPE html> <html> <head lang="en ...
- 【Angular】关于angular引用第三方组件库无法改变其组件样式 :host ::ng-deep
[Angular]关于angular引用第三方组件库无法改变其组件样式 :host ::ng-deep css修改:无效 .ant-input-affix-wrapper .ant-input:not ...
随机推荐
- 【LeetCode】102 - Binary Tree Level Order Traversal
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, ...
- C#轻量级企业事务 - TransactionScope
using System; using System.Data.SqlClient; using System.Transactions; namespace SomeDBTransaction { ...
- 数往知来C#之 正则表达式 委托 XML<六>
C# 正则表达式篇 一.正则表达式 正则表达式就是一个字符串,不要想着一下子可以写出一个通用的表达式,先写,不正确再改 写正则表达式就是在找规律 关键字:Regex -->引入命名空间 ...
- 淘宝的ruby镜像已无人维护,使用ruby-china的RubyGems镜像
淘宝的镜像已经无人维护了,参考 https://ruby-china.org/topics/29250 https://gems.ruby-china.org/ 使用新的镜像 $ gem source ...
- sqlserver安装相关问题
最近在部署一个工程,数据库(sqlserver2005develop)遇到不少问题,下面将一一列出. 安装完毕后,无法连接到本地实例. 打开microsoft sql server 2005-> ...
- virtualenv 和 virtualenvwrapper 实践
virtualenv 首先来聊一下 virtualenv 是个什么鬼. 在使用 Python 开发的过程中,工程一多,难免会碰到不同的工程依赖不同版本的库的问题:亦或者是在开发过程中不想让物理环境里充 ...
- 第二百一十八天 how can I 坚持
真的是自以为是吗?或许是我想太多. 今天下雪了,2015年入冬以来的第一场雪,好冷. 又是一周. 睡觉吧,明天老贾生日. 没啥了,中午有点肚子疼,冬天了要注意.
- OperateParticleWithCodes
[OperateParticleWithCodes] Listing 6-6 shows how you might configure an emitter’s scale property. Th ...
- 使用aspose.word两句代码将word转换为pdf
//Load Document Document document = new Document(@"C:\Users\Administrator\Desktop\人事---新员工转正总结( ...
- DefWndProc/WndProc/IMessageFilter的区别
谈到Winform的消息处理,多数时候是通过事件处理程序进行的,但当没有对应的事件时通常的做法是声明DefWndProc或者WndProc或者IMessageFilter,经常在网上看见有文章将三者并 ...