I have the following HTML:
<ng-view>
<tabset>
<tab>
<tab-heading>
<i class="glyphicon glyphicon-info-sign"></i>
</tab-heading>
<div>
<div>
<div>{{selectedWord.translation}}</div>
</div>
...
</ng-view>
And the controller which is loaded for the view:
angular.module('app').controller('SampleController', function ($scope) {
$scope.selectedWord = {translation: '[te]'};
}
The directive ng-view
creates a new scope which I presume then is injected into the SampleController
constructor as a parameter.
tabset
creates its own isolated scope so it doesn't inherit properties from the scope created by the ng-view
.
.directive('tabset', function() {
return {
restrict: 'EA',
transclude: true,
replace: true,
scope: {
type: '@'
},
Each tab
directive also creates its own scope which also is not inherited from the scope created by the tabset
directive.
.directive('tab', ['$parse', function($parse) {
return {
require: '^tabset',
restrict: 'EA',
replace: true,
templateUrl: 'template/tabs/tab.html',
transclude: true,
scope: {
active: '=?',
heading: '@',
onSelect: '&select', //This callback is called in contentHeadingTransclude
//once it inserts the tab's content into the dom
onDeselect: '&deselect'
},
What I don't understand is why it is possible to access the property selectedWord.translation
defined in the scope created by the ng-view
directive from inside the scope created by the tab
directive (which is isolated scope itself and is preceded by the isolated scope created by the tabset
) ?