I'm trying to change the tab using code and can't seem to figure out the error. The basic thing works if we use the controller to change the variable but when I try to bind it through directive, it brokes.
var app = angular.module('MyApp', ['ngMaterial']);
app.controller('HelloCtrl', function($scope) {
$scope.selectedTab = 0;
});
app.directive('something', function() {
return {
restrict: 'E',
template: '<div ng-click="changeNavigation()">Change Navigation</div>',
scope: {
selectedTab: '='
},
controller: function($scope) {
$scope.changeNavigation = function() {
console.log('Hello World');
$scope.selectedTab = 2;
};
}
};
});
You can view the working code with error on codepen: http://codepen.io/piyushchauhan2011/pen/rVRqeV?editors=101
The error is: