Saad Mahmood Saad Mahmood - 5 months ago 36
AngularJS Question

Error: [$injector:unpr] Unknown provider: interpolateFilterProvider <- interpolateFilter

I am using this angular-seed project https://github.com/angular/angular-seed and replaced ng-route with ui-router. It is almost done by i didn't find how to solve this error.

Here is the full error:



angular.js:9503 Error: [$injector:unpr] Unknown provider: interpolateFilterProvider <- interpolateFilter
http://errors.angularjs.org/1.2.13/$injector/unpr?p0=interpolateFilterProvider%20%3C-%20interpolateFilter
at angular.js:78
at angular.js:3556
at Object.getService [as get] (angular.js:3683)
at angular.js:3561
at Object.getService [as get] (angular.js:3683)
at Parser.$filter (angular.js:13972)
at Parser.filter (angular.js:10090)
at Parser.filterChain (angular.js:10081)
at Parser.statements (angular.js:10056)
at Parser.parse (angular.js:9935)

Here is my full code

app.js



var myApp=angular.module('myApp', [
'ui.router',
'myApp.view1',
'myApp.view2'
]);
myApp.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {

$urlRouterProvider.otherwise('/view1');
}]);


view1.js



var myApp = angular.module('myApp.view1', ['ui.router']);

myApp.config(function($stateProvider, $urlRouterProvider) {

$urlRouterProvider.otherwise('/view1');

$stateProvider

.state('view1', {
url: '/view1',
templateUrl: 'view1/view1.html',
controller: 'View1Ctrl'
});
});

myApp.controller('View1Ctrl', [function() {

}]);


view2.js



var myApp = angular.module('myApp.view2', ['ui.router']);

myApp.config(function($stateProvider, $urlRouterProvider) {

$urlRouterProvider.otherwise('/view2');

$stateProvider

.state('view2', {
url: '/view2',
templateUrl: 'view2/view2.html',
controller: 'View2Ctrl'
});
});

myApp.controller('View2Ctrl', [function() {

}]);


view1.html



<div ui-view>This is the partial for view 1.</div>


view2.html



<p>This is the partial for view 2.</p>
<p>
Showing of 'interpolate' filter:
{{ 'Current version is v%VERSION%.' | interpolate }}
</p>


index.html



<!DOCTYPE html>
<html ng-app="myApp">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>My AngularJS App</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="bower_components/html5- boilerplate/dist/css/normalize.css">
<link rel="stylesheet" href="bower_components/html5-boilerplate/dist/css/main.css">
<link rel="stylesheet" href="app.css">
<script src="bower_components/html5-boilerplate/dist/js/vendor/modernizr-2.8.3.min.js"></script>
<script src="http://code.angularjs.org/1.2.13/angular.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.8/angular-ui-router.min.js"></script>
</head>
<body ng-app="myApp">

<div ui-view></div>
<ul class="menu">
<li><a ui-sref="view1">view1</a></li>
<li><a ui-sref="view2">view2</a></li>
</ul>


<div>Angular seed app: v<span app-version></span></div>

<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="app.js"></script>
<script src="view1/view1.js"></script>
<script src="view2/view2.js"></script>
<script src="components/version/version.js"></script>
<script src="components/version/version-directive.js"></script>
<script src="components/version/interpolate-filter.js"></script>
</body>
</html>

Answer

Try injecting myApp.version on your app.js.

var myApp=angular.module('myApp', [
  'ui.router',
  'myApp.view1',
  'myApp.view2',
  'myApp.version'
]);
myApp.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {

$urlRouterProvider.otherwise('/view1');
}]);
Comments