When binding an object directly to a controller ng-click doesn't work with ng-button ie:
app.controller('ConfigCtrl', function () {
var config = this;
config.nextTab = function (){
console.log('Doesn't work');
};
});
<md-button class="md-raised md-cornered md-primary" ng-click="config.nextTab()">Next</md-button>
But this works :
app.controller('ConfigCtrl', function ($scope) {
$scope.nextTab = function (){
console.log('Doesn't work');
};
});
<md-button class="md-raised md-cornered md-primary" ng-click="nextTab()">Next</md-button>
Am I missing something obvious?
That's the behavior of AngularJS.
If you want to use the nextTab Function without using $scope you should provide a variable name for your controller.
ng-controller="ConfigCtrl as config"
and then you can use your this.nextTab function as followed -> config.nextTab()
Take a look at http://codetunnel.io/angularjs-controller-as-or-scope/
Arrghhh.. stupid typo was to blame..
Most helpful comment
That's the behavior of AngularJS.
If you want to use the
nextTabFunction without using $scope you should provide a variable name for your controller.ng-controller="ConfigCtrl as config"and then you can use your
this.nextTabfunction as followed ->config.nextTab()Take a look at http://codetunnel.io/angularjs-controller-as-or-scope/