Javascript 非注入角模

Javascript 非注入角模,javascript,ruby-on-rails,angularjs,Javascript,Ruby On Rails,Angularjs,我的应用程序在开发或测试模式下运行良好,无论rails s做什么,但在生产模式下运行时不起作用 我的浏览器中出现以下错误 X GET http://localhost:4000/assets/application-bee14c2d11d9c46d50378b54dd87850181256a24c05d6ed2e72c0487fc775f86.js X GET http://localhost:4000/assets/application-c7fa74d0d86da1dddcd65188a0a

我的应用程序在开发或测试模式下运行良好,无论rails s做什么,但在生产模式下运行时不起作用 我的浏览器中出现以下错误

X GET http://localhost:4000/assets/application-bee14c2d11d9c46d50378b54dd87850181256a24c05d6ed2e72c0487fc775f86.js
X GET http://localhost:4000/assets/application-c7fa74d0d86da1dddcd65188a0ad91600d0d55a1be66ba476307822b2d36848b.css
(由于某些原因,也无法在端口3000上运行,但
lsof-i tcp:3000
不会产生任何结果,可能这与此有关?我明白了

Exiting
/Users/jrogers2/.rvm/gems/ruby-2.2.3/gems/puma-3.6.2/lib/puma/binder.rb:266:in 'initialize': Address already in use - bind(2) for "::1" port 3000 (Errno::EADDRINUSE)
    from /Users/jrogers2/.rvm/gems/ruby-2.2.3/gems/puma-3.6.2/lib/puma/binder.rb:26
)

我被告知这是一个手动依赖注入问题,但我不相信,因为我已经环顾了很多地方,尝试了许多不同的格式。但下面是我的代码和完整回购的一些示例

// app.js
(function(){
  'use strict';
  angular
    .module('app', ['templates', 'ui.router', 'Devise', 'ngResource', 'ngMessages', 'infinite-scroll', 'ngFileUpload'])
    .run(['Auth', function(Auth){
      Auth.currentUser()
    }])
}())

//application.js
//= require jquery
//= require angular
//= require angular-devise
//= require angular-messages
//= require angular-ui-router
//= require angular-resource
//= require bootstrap-sprockets
//= require moment
//= require angular-rails-templates
//= require ngInfiniteScroll
//= require ng-file-upload
//= require ng-file-upload-shim
//= require_tree .

// routes.js
(function(){
  'use strict';
  angular
    .module('app')
    .config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider){
      $stateProvider
        .state('login', {
          url: '/',
          templateUrl: 'views/login.html',
          controller: 'loginController as loginCtrl',
          onEnter: ['$state', 'Auth', function($state, Auth){
            Auth.currentUser().then(function(data){
              $state.go('list', {id: data.list.id})
            })
          }]
        })
      $stateProvider
        .state('userPurchases', {
          url: '/users/:id/purchases',
          templateUrl: 'views/purchases.html',
          controller: 'purchaseController as purchaseCtrl',
          onEnter: ['$state', 'Auth', function($state, Auth){
            if (!Auth._currentUser){
              $state.go('login')
            }
          }]
        })

// listController.js
(function(){
  'use strict';
  var listController = ['$scope', 'Auth', '$stateParams', 'itemFactory', 'listFactory', function($scope, Auth, $stateParams, itemFactory, listFactory){
    var listCtrl = this;
    Auth.currentUser().then(function(data){
      $scope.currentUser = data;
    });
    $scope.itemsCounter = 0;
    $scope.list = listFactory.get({id: $stateParams.id});
    $scope.items = [];
    $scope.createItem = function(input){
      input.plzrender = 'list';
      input.items.list_id = $scope.currentUser.list.id;
      itemFactory.save(input).$promise.then(function(response){
        $scope.list = response;
      });
    }
    $scope.deleteItem = function(item){
      item.plzrender = 'list';
      itemFactory.delete(item).$promise.then(function(response){
        $scope.list = response;
      });
    }
    $scope.disableInfinite = false;
    $scope.loadMore = function(list){
      if ($scope.list.$resolved) {
        for (var i = 0; i < 10; i++) {
          $scope.items.push($scope.list.items[$scope.itemsCounter]);
          $scope.itemsCounter += 1;
          if ($scope.itemsCounter >= $scope.list.items.length) {
            $scope.disableInfinite = true;
            break;
          }
        }
      }
    }
    $scope.list.$promise.then(function(response){
      $scope.loadMore();
    });
  }];
  angular
    .module('app')
    .controller('listController', listController)
}())
//app.js
(功能(){
"严格使用",;
有棱角的
.module('app',['templates','ui.router','designe','ngResource','ngMessages','infinite scroll','ngFileUpload']))
.run(['Auth',函数(Auth){
Auth.currentUser()
}])
}())
//application.js
//=需要jquery
//=需要角度
//需要有角度的装置
//=需要角度信息
//=需要角度ui路由器
//=需要角度资源
//=需要引导链轮
//=需要时刻
//=需要角度轨道模板
//=需要ngInfiniteScroll
//=需要上传ng文件
//=需要ng文件上载垫片
//=需要一棵树。
//routes.js
(功能(){
"严格使用",;
有棱角的
.module('应用程序')
.config(['$stateProvider','$urlRouterProvider',函数($stateProvider,$urlRouterProvider){
$stateProvider
.state('登录'{
url:“/”,
templateUrl:'views/login.html',
控制器:“作为loginCtrl的loginController”,
onEnter:['$state','Auth',函数($state,Auth){
Auth.currentUser().then(函数(数据){
$state.go('list',{id:data.list.id})
})
}]
})
$stateProvider
.state('userPurchases'{
url:“/users/:id/purchases”,
templateUrl:'views/purchases.html',
控制器:“purchaseController作为purchaseCtrl”,
onEnter:['$state','Auth',函数($state,Auth){
如果(!Auth.\u currentUser){
$state.go('login')
}
}]
})
//listController.js
(功能(){
"严格使用",;
var listController=['$scope','Auth','$stateParams','itemFactory','listFactory',函数($scope,Auth,$stateParams,itemFactory,listFactory){
var listCtrl=this;
Auth.currentUser().then(函数(数据){
$scope.currentUser=数据;
});
$scope.ItemsCenter=0;
$scope.list=listFactory.get({id:$stateParams.id});
$scope.items=[];
$scope.createItem=函数(输入){
input.plzrender='list';
input.items.list_id=$scope.currentUser.list.id;
itemFactory.save(输入)$promise.then(函数(响应){
$scope.list=响应;
});
}
$scope.deleteItem=函数(项){
item.plzrender='list';
itemFactory.delete(item)。$promise.then(函数(响应){
$scope.list=响应;
});
}
$scope.disableInfinite=false;
$scope.loadMore=函数(列表){
如果($scope.list.$resolved){
对于(变量i=0;i<10;i++){
$scope.items.push($scope.list.items[$scope.itemsCenter]);
$scope.ItemsCenter+=1;
如果($scope.itemsCenter>=$scope.list.items.length){
$scope.disableInfinite=true;
打破
}
}
}
}
$scope.list.$promise.then(函数(响应){
$scope.loadMore();
});
}];
有棱角的
.module('应用程序')
.controller('listController',listController)
}())

github repo:

这看起来确实像是JavaScript缩小问题。请尝试在
production.rb
中禁用资产压缩(仅适用于您的JS)。有关如何执行此操作的更多帮助,请参阅

我相信这应该可以解决您的问题。但经过进一步分析,我在缩小的JS for UI路由器中看到了以下代码:

function() {
  "use strict";
  angular.module("app").config(function(e, t) {
    e.state("login", {
        url: "/",
        templateUrl: "views/login.html",
        controller: "loginController as loginCtrl",
        onEnter: function(e, t) {
          t.currentUser().then(function(t) {
            e.go("list", {
              id: t.list.id
            })
          })
        }
      }),
      e.state("userPurchases", {
        url: "/users/:id/purchases",
        templateUrl: "views/purchases.html",
        controller: "purchaseController as purchaseCtrl",
        onEnter: function(e, t) {
          t._currentUser || e.go("login")
        }
      }).state("userEvents", {
        url: "/users/:id/events",
        templateUrl: "views/events.html",
        controller: "eventController as eventCtrl",
        onEnter: function(e, t) {
          t._currentUser || e.go("login")
        }
      }).state("userProfile", {
        url: "/users/:id",
        templateUrl: "views/profile.html",
        controller: "profileController as profileCtrl",
        onEnter: function(e, t) {
          t._currentUser || e.go("login")
        }
      }).state("userProfileEdit", {
        url: "/users/:id/edit",
        templateUrl: "views/editProfile.html",
        controller: "editProfileController as editProfCtrl",
        onEnter: function(e, t) {
          t._currentUser || e.go("login")
        }
      }),
      e.state("userFriends", {
        url: "/users/:id/friends",
        templateUrl: "views/friends.html",
        controller: "friendshipController as friendshipCtrl",
        onEnter: function(e, t) {
          t._currentUser || e.go("login")
        }
      }),
      e.state("list", {
        url: "/list/:id",
        templateUrl: "views/list.html",
        controller: "listController as listCtrl",
        onEnter: function(e, t) {
          t._currentUser || e.go("login")
        }
      }),
      e.state("listItemEdit", {
        url: "/list/:list_id/items/:item_id/edit",
        templateUrl: "views/items/edit.html",
        controller: "itemController as itemCtrl",
        onEnter: function(e, t) {
          t._currentUser || e.go("login")
        }
      }).state("listItemShow", {
        url: "/list/:list_id/items/:item_id",
        templateUrl: "views/items/show.html",
        controller: "itemController as itemCtrl",
        onEnter: function(e, t) {
          t._currentUser || e.go("login")
        }
      }),
      t.otherwise("/")
  })
}()

而且没有提到
e
t
在哪里。我想这应该是你的罪魁祸首。

谢谢你用
e
t
确认我的怀疑,但我不知道它们代表什么。试着从另一个问题上解决。再次感谢