Ethan May
Ethan May

Reputation: 1292

AngularJS application initializes only half of the time, throws no errors

Used the yeoman angular generator to scaffold out a fresh ng1 app. Had the following basic code for my main module. Notice that I am using ui-router for my routing system.

'use strict';

angular

  .module('myApp', [
    'ngMessages',
    'ngResource',
    'ngSanitize',
    'ui.router'
  ])

  .config([ '$stateProvider', '$urlRouterProvider', function( $stateProvider, $urlRouterProvider ) {

    console.log('config');

    $stateProvider

        .state({
          name: 'main',
          url: '/',
          templateUrl: 'views/main.html',
          controller: 'MainCtrl'
        });

    $urlRouterProvider.otherwise('/');

  }])

  .run([ function() {
    console.log('run');
  }]);

I triple checked that all the necessary files were referenced properly. My angular application only initializes half of the time when I refresh the page. No errors are logged to the console, my state won't load, and none of the console.log statements show up either.

Upvotes: 0

Views: 34

Answers (1)

Ethan May
Ethan May

Reputation: 1292

Turned out the problem was with the "AngularJS Batarang" Chrome extension. Version is 0.10.7 at the time of this post. I am not sure what was causing the interference, but Batarang was killing the application before it even loaded. Once I disabled this extension the application runs properly every time. It took me a bit to solve and hope this saves others some time.

Upvotes: 1

Related Questions