Angular2 Ng对于点击切换不起作用

时间:2017-09-14 09:54:44

标签: angular toggle

我正在开发一个angular2项目,在组件(html)中我有这个     结构:

string

在我的组件(.ts)中,当我尝试下面的代码片段时:假设     当点击但没有发生任何事情时隐藏Mylabel的内容

<ul class="nav nav-list" >
                <li> 
                   <label class="tree-toggler nav-header">
                     <i class="fa fa-plus-circle" aria-hidden="true">
                        </i>Mylabel  
                   </label>
                </li>
                <ul class="nav nav-list tree">
                   <label class="groupcompte">
                     <i class="fa fa-plus-circle" aria-hidden="true">
                       </i>group_name: 
                   </label>
                   <ng-container>
                      <!-- contain of group-->
                   </ng-container>
                </ul>
</ul> 

我做错了什么?

1 个答案:

答案 0 :(得分:0)

使用带有角度的jQuery不是一个好主意..为什么不在模板中使用元素的click事件并将其与组件中定义的事件处理程序绑定:

<button (click)="this.handleMe()">Button</button>

检查这一点,以便在不使用jQuery的情况下更好地理解How to perform DOM manipulation in Angular components

相关问题