0

I am trying to create a sample Angular app with .Net, just to get the idea how to connect two of them but I can not get rid of this injector::modulerr error. Tried variety of things, changing dependencies, removing empty brackets and so on but nothing changes. I have created plunker to keep this thread cleaner the link is below.

http://plnkr.co/edit/5AHsUSrFib4dkiX6XjLY?p=preview

I think the error keeps coming from this one

angular.module('angularTest', ['ngRoute']).config(['$routeProvider', '$routeParams', '$httpProvider',
    function ($routeProvider, $routeParams, $httpProvider) {
        console.log('1');
        $routeProvider.
            when('/routeOne', {
                templateUrl: 'routesDemo/one'
            })
            .when('/routeTwo/:donuts', {
                templateUrl: function (params) { return '/routesDemo/two?donuts=' + params.donuts }
            })
            .when('/routeThree', {
                templateUrl: 'routesDemo/three'
            })
            .when('/login?returnUrl', {
                templateUrl: '/Account/Login',
                controller: LoginController
            });
        console.log('2');
        $httpProvider.interceptors.push('AuthHttpResponseInterceptor');
    }
]);

Thanks for your time.

1 Answer 1

1

$routeParams should be post fix with Provider as you can only use provider in config phase.

Also you should always define app only once then append it by using that module, recreating angular.module will flush the old app & new copy will treated as that module. In you service & controller you need to make change from angular.module('angularTest',[]) to angular.module('angularTest')

Additionally you missed to add ' on LogInController

  .when('/login?returnUrl', {
     templateUrl: '/Account/Login',
     controller: 'LoginController' //<--here added qoutes
  });

One last thing, you missed to add AuthHttpResponseInterceptor.js which was not recognize by the angular app and was throwing AuthHttpResponseInterceptor factory not defined.

Working Plunkr

Sign up to request clarification or add additional context in comments.

7 Comments

I wasnt sure about $routeParams, since I am not using it directly in config it is not needed, am I right? Removing it, doesnt change anything. Also when I remove square brackets from angular.module('angularTest', []) it starts complaining that I missed it or forgot a dependency.
@DasBoot there are many mistakes in your code..let me collect them all..& I'm updating my answer with fix..
@DasBoot thats completed my analysis..I updated answer with working plunkr..do look at it..Thanks :)
It looks like the same plunker I gave or I am missing something :). Thanks for your time
@DasBoot ohh sorry..Thats my bad..look at my edit now..it should be clear to you now.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.