I've been struggling to change the tab using code and can't seem to figure out what's causing the error. It works fine when I use the controller to change the variable, but when trying to bind it through a directive, it breaks.
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 see the code with the error on CodePen here: http://codepen.io/piyushchauhan2011/pen/rVRqeV?editors=101
The error can be seen in this image: https://i.stack.imgur.com/LG1VQ.png