0

I have same directive's example in jsFiddle and another one in plnkr. In jsFiddle, I have to click the text twice to change the text while in plnkr it works like expected with one . Can someone point it out if this is an expected behavior or just a bug in fiddle.

http://jsfiddle.net/z6bfC/

http://plnkr.co/edit/2Z1u2PzbRzPYzjPv4miG?p=preview

HTML:

<div ng-app="testModule">
    <div ng-controller="MyCtrl">
        <div>{{test}}
            <br/>
            <test-directive class="width" bindme="test" style="color: red;">Click Me Twice!!</test-directive>
        </div>
    </div>
</div>

Directive/Controller:

angular.module('testModule', []).directive('testDirective', function () {
    return {
        restrict: 'E',
        scope: {
            bindme: "="
        },
        link: function (scope, element, attr) {

            element.bind('click', function () {
                scope.bindme = "Changed";
                if (!scope.$$phase) {
                    console.log(scope.bindme);
                    scope.$apply();
                } else {
                    console.log("Something");
                }
            });

        }
    };
}).
controller('MyCtrl', function ($scope) {
    $scope.test = "Some string";       
});

Thanks!

1 Answer 1

1

It seems the AngularJS 1.1.0 does some funky stuff.

Try 1.1.1. http://code.angularjs.org/1.1.1/angular.min.js

2
  • You honestly should skip the whole 1.1.x line — 1.2.0rc1 is out, and it's going to be the stable version of the 1.1.x line. Aug 29, 2013 at 21:41
  • I actually only recommend to use the stable version which is 1.0.7
    – zs2020
    Aug 29, 2013 at 21:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.