Monthly Archives: July 2015

angular js calling services twice – Angular JS

Hey everyone,

I had a few of my AngularJS services being called twice. The issue turned out to be that I’d added a controller to both my route and my view:

app.config(function ($routeProvider) {
    $routeProvider
		.when('/', {
		    controller: 'ProjectsController', /* <---- here */
		    templateUrl: '/Home/Home'
		})
<div>
    <ul ng-controller="ProjectsController"><!-- <-- here -->
        <li ng-repeat="project in projects">
            <b>{{project.Name}}</b>
        </li>
    </ul>
</div>

Removing it from the controller resolved the issue. Check out the following StackOverflow post for more info: http://stackoverflow.com/a/15535724/522859

Error: $injector:modulerr Module Error – AngularJS

Hey everyone,

Just getting back into angularjs and I came across the following error:

Unknown provider: $routeProvider

It turns out I that while I had included the route provider file I had missed adding it to the app:

 
//Original
var app = angular.module('commandsApp', [']);
 
//Fixed
var app = angular.module('commandsApp', ['ngRoute']);

Check out the following links if you’re still having issues:
http://plnkr.co/edit/zbG9Vycrxk6mmlzwfTRm?p=preview
https://docs.angularjs.org/api/ngRoute/provider/$routeProvider