I try to change the value in scoop via ng-click , ng-click='currentTab = 1' or ng-click='currentTab = 2' , these are the “Normal” buttons, thus $scope.currentTab will change its value. There is also a 3rd “Funk” button that also changes the currentTab value, but already using the function in the controller. And when I click on "Funk" - the correct number is assigned, by clicking on "Normal" - it changes, but after the "Normal" button "Funk" the button no longer works. The function in the controller for the "Funk" button is simple:

 $scope.change = function() { $rootScope.currentTab = 1; } 

In this case, it is not interesting why it doesn’t want to change it back from the RTC, because in general there should be no difference .. example plankr: https://plnkr.co/edit/yntkXTRS7YC0EgfSNr9k?p=preview

upd: it will work correctly with $ scope, but it’s interesting with $ rootScope what's the matter ..

    1 answer 1

    This is due to the inheritance of the Osprey.

    $rootScope is a top-level $rootScope , its fields / properties / methods are available in all ospes.

    When using the ng-controller directive - it creates its own skop inherited from $rootScope .

    All output in the view is done in the context of the controller Osprey.

    Why does this work the first time?

    If there is no field in the object, this field is searched for in the object prototype. In this case, after pressing the button with the function, the property is added to $rootScope , which is the prototype of the current Osprey, and since there is no this property in the current Osprey, the value set in $rootScope .

    Why does not work after pressing the buttons?

    When you press the remaining buttons - the field is added directly to the current Osp.

    And the value is taken directly from it.

    • I understood, clearly and clearly) thanks! - YoroDiallo pm