Javascript ';的意义是什么;?ngModel';当创建AngularJS指令时?

Javascript ';的意义是什么;?ngModel';当创建AngularJS指令时?,javascript,angularjs,angularjs-directive,Javascript,Angularjs,Angularjs Directive,我正在努力读完这本新书。关于过滤器的章节包括一节,介绍如何使用以下代码定义解析器: angular.module('myApp') .directive('oneToTen', function() { return { require: '?ngModel'; 我第一次看到“?ngModel”语法,AngularAPI文档并没有提供太多帮助。这个语法意味着什么 谢谢 ?是可选指令,^是父指令 所需的可解释为: [?][^][directiveName] 它用于指定应

我正在努力读完这本新书。关于过滤器的章节包括一节,介绍如何使用以下代码定义解析器:

angular.module('myApp')
.directive('oneToTen', function() {
    return {
        require: '?ngModel';
我第一次看到“?ngModel”语法,AngularAPI文档并没有提供太多帮助。这个语法意味着什么


谢谢

是可选指令,
^
是父指令


所需的可解释为:

[?][^][directiveName]

它用于指定应使用哪个指令控制器(“继承自”)。例如,指令
需要找到父控制器
。有几个符号可以与此属性一起使用,也可以组合使用:

^=表示查找DOM以查找指令的角度

?=它指示angular指令是可选的,如果未找到,angular不会引发异常

因此,?ngModel表示ngModel需要与本指令一起声明

(no prefix) - Locate the required controller on the current element. Throw an error if not found.
? - Attempt to locate the required controller or pass null to the link fn if not found.
^ - Locate the required controller by searching the element's parents. Throw an error if not found.
?^ - Attempt to locate the required controller by searching the element's parents or pass null to the link fn if not found.