javascript - 如何在angularjs中为图标(从css生成)编写jquery切换功能?
问题描述
我有一个场景,我需要在移动设备中折叠页脚,我尝试使用 css 媒体查询和 jquery 切换功能。但是,我需要使用 angularjs。我尝试使用 ng-show/ng-hide。但是在这里,'+'或'-'来自css。所以,我需要如何为这些标志提供点击操作。必须动态提供点击功能。
脚本:
$( ".widget h2" ).click(
function() {
$(this).parent().toggleClass('active');
}
);
我需要 angularjs 中的上述代码。
这是我的Plunker
提前致谢。
解决方案
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
推荐阅读
- angular - 无法在 Angular 中使用 Bootstrap 库
- django - 我无法使用 gunicorn 将 IP:8000 更改为 mysite.com:8000
- logging - 如何生成其公钥仅有权写入任何文件的 PGP 密钥?
- vim - 如果没有文件被指定为 cli 参数,则使用 :browse old 启动 vim
- python - 奇怪的行为布尔就地操作
- java - 尝试在 Spring Boot 应用程序中实现 Google Calendar API 时,命令行客户端(或 gradle)出现问题?
- c# - SQL Server 参数化 SQL 查询 - 我还需要转义引号吗?
- python - 通过解压缩打包的 rgb numpy 数组来创建新的 numpy 数组的 Pythonic 方式
- open-source - 使用 Curl 从 artifactory 的通用存储库中检索最新的
- javascript - Number 在客户端 Javascript 中更改其值