我在将js文件部署到heroku时出现问题。
当我为我的角度模块添加组件时问题就开始了
var keysApp = angular.module('keys',['mgo-angular-wizard']);
所以application.js中的代码
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require bootstrap-sprockets
//= require_directory ./bootstrap
//= require mandrill/json2
//= require mandrill/mandrill.min
//= require libs/underscore-min
//= require angular/angular
//= require angular/angular-wizard.min
(function(){
var keysApp = angular.module('keys',['mgo-angular-wizard']);
keysApp.controller('KeysServiceController', function($scope){
$scope.keysServiceModel = keysServicePriceGlobal;
$scope.chosen = "";
$scope.chosenPoint = "";
$scope.userName = undefined;
$scope.userEmail = undefined;
$scope.userPhone = undefined;
var myMap;
var myGroup;
var orderMailer = new mandrill.Mandrill('');
ymaps.ready(init);
function init(){
myMap = new ymaps.Map("map", { center: [59.939095,30.315868], zoom: 10 });
myGroup = new ymaps.GeoObjectCollection({}, {
draggable: false
});
function addObjectToKeyMap(place) {
var geocoder = new ymaps.geocode( place.address, { results: 1 } );
geocoder.then(function (res) {
place.coords = res.geoObjects.get(0).geometry.getCoordinates();
myGroup.add(new ymaps.Placemark(place.coords,{
balloonContentBody: place.address,
id: place.id
}));
});
}
for(i=0; i< keysDotsModelGlobal.length; i++){
addObjectToKeyMap(keysDotsModelGlobal[i]);
}
myMap.geoObjects.add(myGroup);
myGroup.events.add("click",function(e){
var object = e.get('target');
var idOfClickedPlacemark = object.properties.get('id');
var r = $.grep(keysDotsModelGlobal, function(e){ return e.id == idOfClickedPlacemark; });
$scope.editChosenPoint(r[0]);
})
}
$scope.editChosenPoint = function(point){
$scope.chosenPoint = point;
$scope.$apply();
};
$scope.choose = function (service) {
if($scope.isChosen(service)){
$scope.chosen = undefined;
} else {
$scope.chosen = service;
}
};
$scope.isChosen = function(service){
return $scope.chosen === service;
};
$scope.isHeader = function(service){
return service.type == "hr";
};
$scope.closeChosenProduct = function(){
$scope.chosen = undefined;
};
$scope.closeChosenAddress = function(){
$scope.chosenPoint = undefined;
};
$scope.sendOrderRequest = function(){
orderMailer.messages.send({
}
}, function(res){
console.log(res);
}, function(err){
console.log(err)
})
}
});
})();
在发展中,每一件事都很酷。 但在生产中我得到了
未知的提供商错误
my production.rb
config.serve_static_assets = true
# Compress JavaScripts and CSS.
config.assets.js_compressor = false
# config.assets.css_compressor = :sass
我认为无论文件production.rb
中的设置如何,它都会压缩js文件答案 0 :(得分:8)
我在生产模式下使用角度应用程序时遇到同样的问题。以下更改对我有用。
config.assets.js_compressor = Uglifier.new(mangle: false)
答案 1 :(得分:2)
将这些添加到Gemfile中,这对我来说是在rails 3上运行的
gem 'heroku'
gem 'rails_12factor'
gem 'rails_log_stdout', github: 'heroku/rails_log_stdout'
gem 'rails3_serve_static_assets', github: 'heroku/rails3_serve_static_assets'
在你的情况下值得一试
答案 2 :(得分:0)
你还需要添加//= require self
以包含application.js