如何基于另一个指令逻辑创建 AngularJS 指令? [英] How do I create an AngularJS directive based on another directive logic?

查看:25
本文介绍了如何基于另一个指令逻辑创建 AngularJS 指令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 AngularJS 和创建指令很陌生.

I am pretty new to AngularJS and creating directives.

假设我想要一个延迟的 ng-show",这意味着它应该像 ng-show 一样工作,但是元素应该在 2 秒后可见,而不是立即满足表达式.我不想改变 ng-show 的当前行为,只是为了创建一个新的 ng-delayed-show 指令.

Lets say I wanted a "delayed ng-show", that means it should work like ng-show, but the element should be visible after 2 seconds as opposed to immediately the expression was fulfilled. I don't want to change the current behavior of ng-show, just to create a new ng-delayed-show directive.

谁能给我一个例子或链接到关于如何重用或创建另一个指令的子指令的直接文档?

Can anyone give me an example or link me to direct documentation on how to reuse or create a sub directive of another directive?

推荐答案

您不需要为此创建指令.您可以使用 AngularJS 的动画功能很好地做到这一点,该功能在内部使用称为 easing 的 CSS 功能.

You do not need to create directive for this. You can very well do it using animation capabilities of AngularJS which internally uses CSS capability called easing.

在此处阅读 ngshow 及其动画部分的文档 http://docs.angularjs.org/api/ng.directive:ngShow

Read documentation for ngshow and it's animation section here http://docs.angularjs.org/api/ng.directive:ngShow

由于我对它不是很熟悉,这篇文章可以帮助你http://www.yearofmoo.com/2013/04/animation-in-angularjs.html#how-to-use-animations-in-angularjs

Since i am not very familiar with it, this post can help you http://www.yearofmoo.com/2013/04/animation-in-angularjs.html#how-to-use-animations-in-angularjs

这篇关于如何基于另一个指令逻辑创建 AngularJS 指令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆