Search code examples
javascriptangularjsangularjs-directiveangularjs-scope

AngularJS directive only recognize the 2-way binding type


I've a custom directive with an isolated scope which by itself works fine but only when I bind the directive's attributes with the '=' operator, thus when I define them as a 2 way binding. If I try to change them to a 1 way binding ('<') then I get this error. https://docs.angularjs.org/error/$compile/iscp?p0=xflWorkout&p1=create&p2=%3C&p3=isolate%20scope%20definition

Here is an example of my directive:

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`
        }
}});

Also, I'm using angular 1.4.2.

Even though my app works fine, I'd like to know why is it behaving like this so thanks for any help! :)


Solution

  • Angular 1.4.x does not support one-way binding.