Angularjs Uncaught Error:[$ injector:modulerr] - 我错过了什么?

时间:2016-11-17 22:26:06

标签: javascript angularjs

好吧,启动一个MEAN项目,果然我得到了这个常见的错误信息。我已经引用了旧项目,各种Stack Overflow流问题和其他资源,包括AngularJS本身。我仍然看不出我做错了什么。所以这是我的代码。

我确实在我的索引页面和身体上都有。

我尝试了各种格式,如:

var vidembed = angular.module('vidembed', ['ngRoute', 'ngMaterial']);
		vidembed.config(['$routeProvider', '$httpProvider', function($routeProvider, $httpProvider){....

angular.module('vidEmbed', ['ngRoute'])
  .config(function($routeProvider){...

我的头在旋转。提前致谢!

App.js:

'use strict';

/**
 * @ngdoc overview
 * @name vidEmbed
 * @description
 * # vidEmbed
 *
 * Main module of the application.
 */
angular.module('vidEmbed', ['ngRoute'])
  .config(function($routeProvider){
   
  $routeProvider
      .when('/', {
        templateUrl: 'views/main.html',
        controller: 'MainCtrl',
        controllerAs: 'main'
      })
      .when('/movies', {
        templateUrl: 'views/movies.html',
        controller: 'MoviesCtrl',
        controllerAs: 'movies'
      })
      .when('/create/movie', {
        templateUrl: 'views/movie-add.html',
        controller: 'MovieAddCtrl',
        controllerAs: 'movieAdd'
      })
      .when('/movie/:id', {
        templateUrl: 'views/movie-view.html',
        controller: 'MovieViewCtrl',
        controllerAs: 'movieView'
      })
      .when('/movie/:id/delete', {
        templateUrl: 'views/movie-delete.html',
        controller: 'MovieDeleteCtrl',
        controllerAs: 'movieDelete'
      })
      .when('/movie/:id/edit', {
        templateUrl: 'views/movie-edit.html',
        controller: 'MovieEditCtrl',
        controllerAs: 'movieEdit'
      })
      .otherwise({
        redirectTo: '/'
      })
    
  .directive('youtube', function(){                                     //embeds video onto page
    return{
      restrict: 'E',
      scope:{
        src:'='
      },
      templateUrl: 'views/youtube.html'
    };
  })
  .filter('trusted', function($sce){                                    //allows for emdeding by allowing trusted certificates
    return function(url){
      return $sce.trustAsResourceUrl(url);
    };
  })
})

Movies.js控制器:

'use strict';

/**
 * @ngdoc function
 * @name clientApp.controller:MoviesCtrl
 * @description
 * # MoviesCtrl
 * Controller of the clientApp
 */
angular.module('vidEmbed')
  .controller('MoviesCtrl', function ($scope, MovieFactory, $location, $routeParams){
    
    MovieFactory.getMovies(function(movies){
    	$scope.movies = movies;    	
    })
    
  })

MovieFactory.js:

var vidembed = angular.module('vidEmbed');
vidEmbed.factory('MovieFactory', ['$http', function($http){
	var factory = {};
	factory.getMovies = function(callback){
		$http({
			method:"GET",
			url:"/movies"
		}).then(function(res){
			callback(res.data);
		}, function(res){
			console.log(res);
		})
	}
	factory.getMovie = function(movieId, callback){
		$http({
			method:"GET",
			url:'/movie/'+movieId
		}).then(function success(res){
			callback(res.data);
		})
	}
	return factory;
}])

0 个答案:

没有答案