Perhaps my brain is still not fully functional this morning, but what's the best or proper way to get a variable from a template/view into a controller in Angular?
Say in my view I have defined var a = 'something'
, and I need to access that value inside the controller.
I could do passVariable(a)
on ng-init
, and inside the controller have something like
$scope.passVariable = function(param){
$scope.a = param;
}
But obviously that doesn't work, and the method doesn't seem very right either ;-)