I have a question relating assigning a variable vs a new object in scope. Take the plnkr example where I have an on/off canvas menu (http://plnkr.co/edit/bJsDuEd9QPG65HMdkAIQ?p=info). Within the mainCtrl defined in the app.js file. I have defined two scope variables as follows:
$scope.navLeft= false;
$scope.navRight=false;
In this example I use ng-include which links to the navbar.html that contains the navbar and left nav menu toggle switch. This toggle doesn't work, where I understand ng-include creates a new scope.
However in the next plnkr example (http://plnkr.co/edit/PQOeT61mjZdDWwSbjlyQ?p=preview) the navLeft and navRight are defined within a new object.
$scope.nav = {
navLeft:false,//default navLeft menu off
navRight:false//default navRight menu off
};
This works, that is the navLeft menu is toggled on/off. Question I have, why does the latter example which uses a new object, does not create a new scope thus work? But the first example which defines the navLeft & navRight variable using '=', why does it create a new scope and therefore not work? Appreciate any comments on the topic. Thanks