What does one variable mean in javascript?

I found the syntax as stated in the book about Angular.js.

$scope.selectedOrder; // what does this syntax mean?
$scope.selectOrder = function(order) {
  $scope.selectedOrder = order;
};

I know that selectedOrder is a property of the $ scope object.

But what is the purpose of "$ scope.selectedOrder;".

I do not see any operation from this line. Can someone give me a hint? Thank.

+4
source share
1 answer

I will ever use this template.

For example, if you have a "class":

    function Vehicle() {
            var $scope = this;

            $scope.tyres;  // Public property
            $scope.setTyres = function(num) {
                    $scope.tyres = num;
            }
    }

    var vehicle = new Vehicle();
    vehicle.setTyres(3);
    console.log("Number of tyres", vehicle.tyres)

You publish tires for publication. The reason it is declared outside is to show developers what is public rather than letting it remain hidden in the setTyres function.

+2
source

Source: https://habr.com/ru/post/1546808/


All Articles