programing

레일/앵글 배포 시 알 수 없는 공급자 오류JS 앱에서 헤로쿠로

css3 2023. 10. 22. 20:19

레일/앵글 배포 시 알 수 없는 공급자 오류JS 앱에서 헤로쿠로

레일/각형이 있습니다.현지 개발 환경에서 잘 작동하는 JS 앱.하지만 Heroku the Angular에 이 앱을 배포하면JS가 작동하지 않고 다음 오류를 반환합니다.

Unknown provider: eProvider <- e

제가 좀 조사를 해봤는데 자산을 미리 컴파일하고 최소화하는 것과 관련이 있는 것 같은데 이 문제를 해결하려면 어떻게 해야 할지 모르겠습니다.무슨 생각 있어요?감사합니다!

컨트롤러의 모양은 다음과 같습니다.

function RemindersCtrl($scope, $http) {
  $http.get('/reminders.json').success(function(data) {
    $scope.reminders = data;
    console.log(data);
  });
}

그리고 이것이 보기의 코드입니다.

    %section.reminders
      %div{"ng-controller" => "RemindersCtrl"}
        %ul
          %li{"ng-repeat" => "reminder in reminders"}
            .title {{reminder.title}}

업데이트: 컨트롤러를 이렇게 바꿨지만 결과는 같습니다.

var RemindersCtrl = function($scope, $http) {
  $http.get('/reminders.json').success(function(data) {
    $scope.reminders = data;
    console.log(data);
  });
}
RemindersCtrl.$inject = ['$scope','$http'];

앵귤러에 의하면JS 자습서(http://docs.angularjs.org/tutorial/step_05) 최소화 문제를 방지하기 위해 이 내용을 컨트롤러에 추가할 수 있습니다.

function RemindersCtrl($scope, $http) {
  ...
}
RemindersCtrl.$inject = ['$scope', '$http'];

또는 다음과 같은 함수를 정의하는 대신:

function RemindersCtrl($scope, $http) {
  ...
}

다음과 같이 해야 합니다.

var RemindersCtrl = ['$scope', '$http', function($scope, $http) {
  ...
}];

컨트롤러를 다음과 같이 정의하고 있을 수 있습니다.FooController = function($http) {}, 당신은 다음과 같이 정의해야 합니다.FooController = ["$http", function($http){}]

여기를 봐요

Angular team(그리고 일반적으로 말해서)은 우리가 전 세계를 오염시키지 말 것을 권고합니다.

.controller method,

var myApp = angular.module('myApp',[]);

myApp.controller('GreetingCtrl', ['$scope', function($scope) {
  $scope.greeting = 'Hola!';
}]);

저는 잘 일했어요.이 문서는 각 컨트롤러 설명서에 나와 있습니다.

언급URL : https://stackoverflow.com/questions/13608039/unknown-provider-error-when-deploying-rails-angularjs-app-to-heroku