0

I am learning routing with angular java script , this is my index.html

<html lang="en" ng-app="eventsApp">
.....
<div class="container">
    <div class="navbar">
        <div class="navbar-inner">
            <ul class="nav">
                <li><a href="#/newEvent">Create Event</a></li>
            </ul>
        </div>
    </div>

    <ng-view></ng-view>
</div>

This is my app.js,

var eventsApp = angular.module('eventsApp', ['eventsApp', 'ngRoute'])
    eventsApp.config(function($routeProvider) {
        $routeProvider.when('/newEvent',
            {
                templateUrl:'templates/NewEvent.html',
                controller: 'EditEventController'
            }).....

When i click on the button it do nothing and also doesn't load new event . and get this error

 "Error: [$injector:modulerr] Failed to instantiate module eventsApp due to:"

here is the controller

'use strict';

eventsApp.controller('EditEventController',
    function EditEventController($scope, eventData) {

        $scope.event = {};

        $scope.saveEvent = function (event, form) {
            if(form.$valid) {
                eventData.save(event);
            }
        };

        $scope.cancelEdit = function () {
            window.location = "/EventDetails.html";
        };

    }
);
user3408399
  • 109
  • 1
  • 2
  • 12

1 Answers1

0

One of the things I'm noticing looks wrong is that you're passing in eventsApp as a dependency of itself.

var eventsApp = angular.module('eventsApp', ['eventsApp', 'ngRoute'])

Should be:

var eventsApp = angular.module('eventsApp', ['ngRoute'])

Secondly, you may want to check that you've included ngRoute into the page: See installation instructions here: http://docs.angularjs.org/api/ngRoute

Check out a working example on Plunkr: http://plnkr.co/edit/VZgTnBvi0Q8qtcpOUTx0

omgaz
  • 347
  • 4
  • 11
  • i have done the first part , and for the second i also have it , unless i shouldnt use the MIN file – user3408399 Mar 15 '14 at 05:29
  • Having the min version is fine, that won't make a difference. I'd suggest just comparing your code to my example and try to get it to work for yourself. Also, what version of Angular are you using I assume a recent build? – omgaz Mar 15 '14 at 05:38
  • im doing a tutorial its from 2013, i have put my controller in a different file, that shouldn't make a difference ,right? i have edit with some changes to add the controller – user3408399 Mar 15 '14 at 05:42
  • im using AngularJS v1.2.10 – user3408399 Mar 15 '14 at 05:43
  • It shouldn't be a problem including in multiple files: http://stackoverflow.com/questions/20087627/how-to-create-separate-angularjs-controller-files. And your version of Angular seems fine also. – omgaz Mar 15 '14 at 05:52
  • i think it may have to do with the url , templateUrl:'templates/NewEvent.html', G:\xampp\htdocs\routingAngular\app\templates/NewEvent.html – user3408399 Mar 15 '14 at 06:21