0

I installed AngularJs with MVC4 using Nuget package and created a bundle for AngularJS

 bundles.Add(new Bundle("~/bundles/scripts")
                .Include("~/Scripts/angular.js")
                .Include("~/Scripts/jquery-{version}.js"));

In Layout I included it as follow:

 @Scripts.Render("/scripts/angular-route.js")
  @Scripts.Render("/scripts/loginController.js")
  @Scripts.Render("/scripts/routeConfig.js") 

routeConfig.js

angular
    .module('MyApp', [
    'ngRoute',
    'MyApp.ctrl.crud',
    ])
    .config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {

        $routeProvider.when('/', {
            templateUrl: '/Home/Index',
          //  controller: 'loginController'
        });
        $routeProvider.when('/login', {
            templateUrl: '/Home/loginPage',
            controller: 'crudController'
        });
        $locationProvider.html5Mode({
            enabled: true,
            requireBase: false
        });
    }]);

loginController.js

angular
    .module('MyApp.ctrl.crud', [])
    .controller('loginController', [
        '$scope',
        function ($scope) {
            alert("In Login Controller")
        }
    ]);

When I program is display following exception:

WARNING: Tried to load angular more than once.

Why I get this Warning?

Muhammad Nasir
  • 2,126
  • 4
  • 35
  • 63
  • Are you trying to load partial views in your `Index` or `LoginPage`? This error can appear if you get full page instead of a partial. Say, for example, you expect a partial view (withour `_Layout.cshtml`) but there's an exception on the server and it sends the error page, which might not be a partial. – Andrei V Sep 15 '15 at 08:35
  • I get this too, searched around and found some answers on here: http://stackoverflow.com/questions/22595878/tried-to-load-angular-more-than-once http://stackoverflow.com/questions/23765941/warning-tried-to-load-angular-more-than-once-when-i-include-jquery http://stackoverflow.com/questions/32580640/tried-to-load-angular-more-than-once-with-mvc4 – Ric Sep 15 '15 at 09:11

0 Answers0