I was using controllers like this
.controller("somename",function($scope,$http){
//some get function to fetch data
$scope.data = dataReturned;
$scope.$apply();
});
It was working fine. Then I wanted to use functions after reading johnpapa's blog and changed it to the one like below
.controller("somename",someNameController);
function someNameController(){
var someName = this;
//some get function to fetch data
this.data = dataReturned;
this.$apply();
};
but this did not work as this.$apply is not a function
When I added $scope(which is not recommended) it started working
.controller("somename",someNameController);
function someNameController($scope){
var someName = this;
//some get function to fetch data
$scope.data = dataReturned;
$scope.$apply();
};
is it possible to eliminate the passing of $scope in function someNameController($scope) ?
$scopeas an argument not recommended? Because it breaks on minification (for which, you can use the array or$injectsolutions)? What about other dependency injections?$apply? can you provide sample plunkr?$applynot needed, and jQuery also not needed$http.getit same as$.get