Angular2模态弹出定位左侧

时间:2017-02-18 09:29:15

标签: html css angular typescript modal-dialog

我在angular2中使用This modal,我想将模态弹出窗口放在左侧,这是我尝试过的

ruby -pe '$_ = $_.scan(/\w+/)' file

在css类

<modal #categoriesmodal [cssClass]="modalchecklist">
  <modal-header [show-close]="true">
    <h4 class="modal-title">I'm a modal!</h4>
  </modal-header>
  <modal-body>
    Hello World!
  </modal-body>
  <modal-footer [show-default-buttons]="true"></modal-footer>
</modal>

}

我曾尝试在css类上添加.modalchecklist{ position:absolute; top:0; left:0 ,但这会失败并将css添加到背景文档而不是模态

我在css课程上哪里出错了

我也检查了Chrome开发人员工具,但他们也没有解决这个问题。

可能出现什么问题

1 个答案:

答案 0 :(得分:1)

要在Angular2中应用样式属性,您可以使用[style]指令,如此

<what-ever [style.backgroundColor]="'red'">I am red</what-ever>

要申请课程,请使用ngClass

<what-ever [ngClass]="'first'"><what-ever>
<what-ever [ngClass]="['first', 'second']"></what-ever>
<what-ever [ngClass]="{'first':true, 'second':conditionExp}"><what-ever>

有关多种语法选项和使用表达式,请参阅上面的ngClass链接。

请注意所有这些方法都是指令,并且直接绑定到范围,它们期望表达式。为了传递字符串,您需要将表达式限定为字符串:在双引号中使用单引号,它们将被正确地评估为字符串。