I got this error with below code:
TypeError: undefined is not a function
at Scope.AppCtrl.$scope.refresh
my partial front end that used ng-repeat
<ion-content>
<div class="card list" data-ng-repeat="p in posts">
<div class="item item-avatar-left">
<img data-ng-src="{{p.author.avatar_URL}}">
<h2>{{p.author.nice_name}}</h2>
<p><a href="{{p.author.URL}}"></a>{{p.author.URL}}</p>
</div>
<div class="item item-body">
<h1>{{p.title}}</h1>
<p>{{p.content}}</p>
</div>
</div>
</ion-content>
My app.js file
var App = angular.module('App', ['ionic']);
App.service("FreshlyPressed", ["$http","$log",FreshlyPressed]);
App.controller("AppCtrl", ["$scope", "FreshlyPressed", "$log", AppCtrl]);
function AppCtrl($scope, $log, FreshlyPressed){
$scope.posts = [];
$scope.refresh = function(){
FreshlyPressed.getBlogs($scope);
}
}
function FreshlyPressed($http, $log){
this.getBlogs = function($scope){
$http.jsonp("https://public-api.wordpress.com/rest/v1/freshly-pressed?callback=JSON_CALLBACK")
.success(function(result){
$scope.posts = result.posts;
});
}
}
I pass the $scope and expect it to work, but I got an undienfed error at line FreshlyPressed.getBlogs($scope);