http://ift.tt/1iD2D7J$controller
I have X function in a controller. It performs X task. I have a function Y that performs Y task which included calling X function. I'm trying to stub the behavior of X function and pass it in as a local in my tests:
function someFunction {
return 'some value';
}
controller = $controller('AddToTripCtrl', {
$scope': $scope,
'someFunction': someFunction
})
The above code fails with JavaScript being unable to find someFunction (function X in my description).
Is there a way to simply pass in a function as a local to an AngularJS controller? If so, how? Also, is this a sound method for doing what I attempted to describe?
Aucun commentaire:
Enregistrer un commentaire