AngularJS指令只识别双向绑定类型

AngularJS directive only recognize the 2-way binding type

本文关键字:绑定 类型 识别 指令 AngularJS      更新时间:2023-09-26

我有一个带有隔离作用域的自定义指令,它本身工作良好,但只有当我将指令的属性与'='运算符绑定时,因此当我将它们定义为双向绑定时。如果我试图将它们更改为单向绑定('<'),则会出现此错误。https://docs.angularjs.org/error/$compile/iscp?p0=xflWorkout&p1=创建&p2=%3C&p3=隔离%20范围%20定义

以下是我的指令示例:

angular.module('directive.module', ['directive.dependency'])
.directive('directiveName', function(){
    return {
        restrict: 'E',
        scope: {
            'attr1': '=info',
            'create': '<',
            'attr3': '<',
            'attr4': '=',
            'attr5': '<'
        },
        templateUrl: 'template.html',
        replace: true,
        controller: function($scope, $element, $attrs, $transclude, ...){
            //controller code`enter code here`
        }
}});

此外,我使用的是角1.4.2。

尽管我的应用程序运行良好,但我想知道它为什么会这样,所以感谢您的帮助!:)

Angular 1.4.x不支持单向绑定。