K
K
KoRNeT46RuS2016-12-28 14:00:47
Angular
KoRNeT46RuS, 2016-12-28 14:00:47

Why does the test change the value in the child scope and not in the current one?

There is an event handler

let orthography = $scope.appCTRL.orthography;
                        let url = attributes[DIRECTIVE];

                        element.on('keydown', (_event) => {
                            if (_event.keyCode == 13 && _event.ctrlKey) {
                                orthography.isOpen = true;
                                orthography.text = window.getSelection().toString().trim();
                                if (window.getSelection().focusNode) {
                                    orthography.fragment = window.getSelection().focusNode.data;
                                }
                            }
                        });

And test
document.body.innerHTML =
            '<div data-ng-controller="appController" data-app-orthography="'+ urlOrthography +'" id="js-karma-test">' +
                '<form class="modal-cross">' +
                    '<div class="modal-spelling__close" data-ng-click="appCTRL.orthography.isOpen = false">' +
                        '<i class="fa fa-times"></i>' +
                    '</div>' +
                    '<input type="text" value="бла бла бла" disabled="disabled">' +
                    '<textarea rows="10" cols="45" placeholder="Ваш комментарий" data-ng-model="appCTRL.orthography.comment">коммент</textarea>' +
                    '<input type="submit" value="Отправить" data-ng-click="appCTRL.orthography.onSubmit = true;">' +
                '</form>' +
            '</div>';
        reCompileElementService.replace(angular.element(document.querySelectorAll('#js-karma-test')), scope);
        scope.$digest();

        angular.element(document.querySelector('#js-karma-test')).trigger({type: 'keydown', keyCode: 13, ctrlKey: true});

So... Why does the value of isOpen change in scope.$$childHead.orthography.isOpen and not in scope.orthography.isOpen ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lega, 2016-12-28
@lega

So some directive / controller, or several, creates a child scope and orthography is frayed.
where did appCTRL come from if data-ng-controller="appController" ? perhaps a piece of code is incorrect.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question