1

i am trying to route in angular.js (1.3.15)and getting these two errors :

error messages

1-WARNING: Tried to load angular more than once.

2-angular.js:38Uncaught Error: [$injector:modulerr]
http://errors.angularjs.org/1.3.15/$injector/modulerr?p0=after_login&
p1=Err…0d%20(http%3A%2F
%2Flocalhost%3A49062%2FScripts%2Fangular.min.js%3A17%3A381)

my module.js

var after_login = angular.module("after_login", ['ngRoute', 'CrackWeb']);


after_login.config(['$routeProvider', function ($routeProvider) {

  $routeProvider.when('/groups',
                    {
                        templateUrl: 'Views/p1.cshtml',
                        controller: 'MyScripts/groups'
                    })
              .otherwise(
                        {
                            redirectTo: '/'
                        });
$locationProvider.html5Mode(true).hashPrefix('!');
}]);

in my html page with ng-app i have written.

p1.cshtml [ partial ]

<div class="col-md-9">
    <br />
      <input ng-model="check" id="ch"/>
        {{check}}
      <div ng-view></div>
</div>

Can anyone help ?

amdixon
  • 3,814
  • 8
  • 25
  • 34
trigri
  • 525
  • 1
  • 6
  • 16
  • how about the controller ? – Aysennoussi May 17 '15 at 09:45
  • after_login.controller('groups', function ($scope) { $scope.login = function (userName, pass) { alert(userName+pass); var url = 'http://52.11.190.113/api/account/login'; $http.post(url, { email:userName, password:pass, deviceregistrationid: '67788' }) .success(function (data,$location){ alert("success"+" "+ data.message); }); } }); – trigri May 17 '15 at 09:54
  • did you add ng-app="after_login" in your html ?? – jad-panda May 17 '15 at 09:54
  • here is what i added – trigri May 17 '15 at 09:56

2 Answers2

0

In your route provider you have mentioned

$routeProvider.when('/groups', { templateUrl: 'Views/p1.cshtml', controller: 'MyScripts/groups' }) .otherwise( { redirectTo: '/' });

but you dont have default route

$routeProvider.when('/', { templateUrl: 'sometemplate', controller: 'somecontroller' });

so it will try to load your default HTML(most cases index.html) again and again and it cause the error

Alhuck
  • 1,029
  • 8
  • 11
  • i have otherwise( { redirectTo: '/' }); – trigri May 17 '15 at 10:05
  • you have to mention template and controller for `/` otherwise it will try to load your index.html again !!! – Alhuck May 17 '15 at 10:09
  • [code] $routeProvider.when('/', { templateUrl: 'Views/index.html', controller: 'MyScripts/login_controller' }) i added this code it is not helping – trigri May 17 '15 at 10:14
  • do you have angularjs core file in your index.html!!! if possible add your index.html in your question – Alhuck May 17 '15 at 10:19
  • there was not before now i have added but not helping at all. – trigri May 17 '15 at 10:23
  • you should not load angular core file in your index.html!!! there may be some other reasons causing you problem !!!! will you be able to create a plunker reproducing your issue – Alhuck May 17 '15 at 10:27
  • http://stackoverflow.com/questions/23499853/warning-tried-to-load-angular-more-than-once-angular-js refer this link – Alhuck May 17 '15 at 10:49
  • my url is http://localhost:49062/#/groups but it should be likhttp://localhost:49062/Views/#/groups what should i change in route – trigri May 17 '15 at 10:56
0

You can not load a page with cshtml extension!

Actually you are wrong when you try to load the page CSHTML through the ANGULAR ROUTING. As you can not load this page alone so well you can not load it through ANGULAR route.

So if you want to load a page CSHTML then you have to call his controller in MVC and to load it via 'ActionResult'.

Yuval
  • 547
  • 1
  • 7
  • 14