-2

Can someone please explain to me in this directive what means value:'=editable' and field:'@fieldType' in this directive I am new with learning AngularJS ?

 myApp.directive('editable', function () {
        return {
            restrict: 'AE',
            templateUrl: "Partials/editable.html",
            scope: {
                value: '=editable',
                field: '@fieldType'
            },


            controller: function ($scope) {
                $scope.editor = {
                    showing: false,
                    value: $scope.value
                };

                $scope.field = ($scope.field) ? $scope.field : 'text';

                $scope.toggleEditor = function () {
                    $scope.editor.showing = !$scope.editor.showing;
                }

                $scope.save = function () {
                    $scope.value = $scope.editor.value;
                    $scope.toggleEditor();
                }
            }
        };
    });
jhony3
  • 272
  • 1
  • 2
  • 13
  • Possible duplicate of [What is the difference between '@' and '=' in directive scope in AngularJS?](http://stackoverflow.com/questions/14050195/what-is-the-difference-between-and-in-directive-scope-in-angularjs) – Hanlet Escaño Aug 09 '16 at 21:57

1 Answers1

1

"@" ( Text binding / one-way binding )

"=" ( Direct model binding / two-way binding )

"&" ( Behaviour binding / Method binding )

@ binding is for passing strings

you're simply getting the word you passed in as a string

= binding is for two-way model binding

changes made from the controller will be reflected in the reference held by the directive, and vice-versa

& binding is for passing a method into your directive's scope so that it can be called within your directive.

https://gist.github.com/RobertAKARobin/a02426c375596f0bef89

parthas j
  • 290
  • 2
  • 12