"Error: [$injector:unpr]" <--- This is making me sad

This is my first attempt at writing a controller. The following code worked until I added the two $ionicHistory references. Doing that gave me:

Error: [$injector:unpr] http://errors.angularjs.org/1.2.17/$injector/unpr?p0=%24ionicHistoryProvider%20<-%20%24ionicHistory

I thought including the ionic dependency would be all that was required. Any thoughts?

var fp = angular.module('freshlypressed', ['ionic']);

fp.controller('BlogListCtrl', ['$scope', '$ionicHistory', '$http', function($scope, $ionicHistory, $http){

	console.log('in BlogListCtrl');


hi @deno

you can also define controller like

fp.controller(‘BlogListCtrl’, function($scope, $ionicHistory, $http){


Hi Jari. Is that related to the error I’m getting? AFAIK, the annotation approach is “better” practice to prevent trouble when minifying your JS. Is that not correct?


That did not fix the error. Any other suggestions?

No dano you are not using wrong approach.
Your approach is better with minified js.

I had try your code and it is working. No any error for injection.

I had created ionic starter project and put your controller in app.js file.

You can create is by ionic start cmd


// Ionic Starter App
var fp=angular.module('starter', ['ionic'])

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {

    if(window.cordova && window.cordova.plugins.Keyboard) {
    if(window.StatusBar) {

fp.controller('BlogListCtrl', ['$scope', '$ionicHistory', '$http', function($scope, $ionicHistory, $http){
	console.log('in BlogListCtrl');



<!DOCTYPE html>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <script src="lib/ionic/js/ionic.bundle.js"></script>
    <script src="cordova.js"></script>
    <script src="js/app.js"></script>

  <body ng-app="starter">
      <ion-header-bar class="bar-stable">
        <h1 class="title">Ionic Blank Starter</h1>
      <ion-content class="has-header" ng-controller="BlogListCtrl">

It is showing in BlogListCtrl in console. and deno2 on screen.

I had additionally put $scope.name to check controller is working or not.