Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unknown provider switching from Angular 1.0 to 1.2.3

Tags:

angularjs

I'm trying to migrate from Angular 1.0 to Angular 1.2.3. I have added angular-route.js as a dependency and added ngRoute everywhere I believe it should go. And that is all I've done to move from 1.0 to 1.2.3 I'm getting the following errors:

Error: Unknown provider: $sceProvider <- $sce <- $route <- ngViewDirective

Error: Circular dependency: ngViewDirective

Here is a snippet of the html where my ng-view is:

<div id="wrapper" ng-controller='MyCtrl'>
    <div ng-include src="'application/nav.html'" ng-controller="NavCtrl"></div>
    <div id="content-main" ng-view></div>
</div>

So I have controllers above the ng-view directive in the dom. Neither of these controllers have dependency on ngRoute, just $scope and $location.

This works in 1.0 so it has something to do with moving to 1.2.3 but I'm not seeing the issue.

Does anyone know what I'm missing here?

like image 599
user3058644 Avatar asked Dec 02 '13 19:12

user3058644


2 Answers

In AngularJS 1.2.1, the route module have been pulled out in a single file angular-route.min.js, you need to add the reference to this file and angular-sanitize.min.js according to the error you posted.

And you need to inject ngRoute and ngSanitize in the app as well:

var app = angular.module('nap.application', ['ngRoute', 'ngSanitize']);
like image 100
zs2020 Avatar answered Nov 15 '22 21:11

zs2020


$sce is a security service in AngularJS, are you happening to use ng-bind-html-unsafe in any partials being loaded into ng-vew? If so, you need to change those to ng-bind-html and include the ngSanitize module.

like image 40
m.e.conroy Avatar answered Nov 15 '22 20:11

m.e.conroy