首页 > 解决方案 > 如何在angularjs中为图标(从css生成)编写jquery切换功能?

问题描述

我有一个场景,我需要在移动设备中折叠页脚,我尝试使用 css 媒体查询和 jquery 切换功能。但是,我需要使用 angularjs。我尝试使用 ng-show/ng-hide。但是在这里,'+'或'-'来自css。所以,我需要如何为这些标志提供点击操作。必须动态提供点击功能。

脚本:

$( ".widget h2" ).click(
    function() {
        $(this).parent().toggleClass('active');
    }
);  

我需要 angularjs 中的上述代码。

这是我的Plunker

提前致谢。

标签: javascriptangularjs

解决方案


You could probably use ng-class to toggle css classes based on your conditions. I would personally suggest to avoid using jquery in angularjs projects. For ways on how you can use the ng-class,

you can go through the following blog


推荐阅读