Ошибка AngularJS: [$ injector: unpr] Неизвестный поставщик: $ timeOutProvider <- $ timeOut <- alert

0

Я получаю следующую ошибку и не знаю, почему

Ошибка: [$ injector: unpr] Неизвестный поставщик: $ timeOutProvider <- $ timeOut <- alert

Контроллеры\register.js

angular.module('testApp')
  .controller('RegisterCtrl', function ($scope, $rootScope, $http, alert) {
    $scope.submit = function () {

      var url = '/';
      var user = {};

      $http.post(url, user)
        .success(function (res) {
          alert('Success', 'OK!', 'You are now registered');
        })
        .error(function (err){
          alert('warning', 'Oops!', 'could not register');
        });
    };
  });

услуги\alert.js

angular.module('testApp')
  .service('alert', function ($rootScope, $timeOut) {
    var alertTimeout;
    return function(type, title, message, timeout){
      $rootScope.alert = {
        hasBeenShown: true,
        show: true,
        type: type,
        message: message,
        title: title
      };
      $timeOut.cancel(alertTimeout);
      alertTimeout = $timeout(function() {
        $rootScope.alert.show = false;
      }, timeout || 2000);
    }
  });

app.config.js

angular.module('testApp').config(function ($urlRouterProvider, $stateProvider) {

  $urlRouterProvider.otherwise('/')

  $stateProvider
    .state('main', {
    url: '/',
    templateUrl: '/views/main.html'
  })
  .state('register', {
    url: '/register',
    templateUrl: '/views/register.html',
      controller: 'RegisterCtrl'
  });
})
  • 0
    Служба называется $ timeout, а не $ timeOut.
  • 0
    $timeout - регистр важен
Теги:

1 ответ

1
Лучший ответ

Это timeout не timeOut

.service('alert', function ($rootScope, $timeout) {

Ещё вопросы

Сообщество Overcoder
Наверх
Меню