Angular.dart指令是否等效于AngularJS的"restrict" [英] Has Angular.dart directive an equivalent to AngularJS's `restrict`

查看:67
本文介绍了Angular.dart指令是否等效于AngularJS的"restrict"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在AngularJS中,有一个用于指令(和其他指令)的属性,用于指定是否可以通过元素名称或属性来实例化它,例如元素AND属性的restrict:EA.

In AngularJS there is an attribute for directives (and others) to specify if it can be instantiated by an element name or an attribute - like restrict:EA for element AND attribute.

文件 angular.dart/lib/指令/ng_a.dart 包含注释* @restrict E,该注释指示该指令用于<A> element.

The file angular.dart / lib / directive / ng_a.dart contains a comment * @restrict E which indicates the directive is for the <A> element.

在Angular.dart中是否不需要restrict?
什么是替代品?

Is restrict not necessary in Angular.dart?
What is the replacement?

推荐答案

正确的Angular.dart没有restrict,因此请忽略ng_a.dart中的注释,它可能只是JS版本的复制粘贴.所有指令/组件/控制器均使用selector,因此通常需要非常具体.如果需要等效的restrict:EA,则可以在类上应用两个注释.例如:

Correct, Angular.dart doesn't have restrict, so please disregard the comment in ng_a.dart, it's probably just a copy-paste from JS version. All directives/components/controllers use selector, so you normally need to be very specific. If you need an equivalent of restrict:EA, you could apply two annotations on the class. Ex:

@NgDirective(selector: 'foo')
@NgDirective(selector: '[foo]')
class FooDirective {

}

这篇关于Angular.dart指令是否等效于AngularJS的"restrict"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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