我试图找出应用程序的客户端。我正在使用Angular,当我尝试加载页面时,我得到了
Uncaught Error: [$injector:modulerr] Failed to instantiate module Facebook due to:Error[$injector:nomod] Module 'Facebook' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument. http://errors.angularjs.org/1.3.0-rc.5/$injector/nomod?p0=Facebook
我已下载并包含angular-route和angular-resources,它们都在application.js之前编译,并且我已将我的ng-app从html标记移动到body标记。
知道我能做些什么来让这个工作吗?让模块工作似乎很简单,但它拒绝。
-application.html.erb
<!DOCTYPE html>
<html>
<head>
<script src="/assets/angular/angular.js" type="text/javascript"></script>
<script src="/assets/angular/angular-resource.js" type="text/javascript"></script>
<script src="/assets/angular/angular-route.js" type="text/javascript"></script>
<%= javascript_include_tag "application" %>
<%= stylesheet_link_tag "application", media: "all" %>
<%= csrf_meta_tags %>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<script>
<![endif]-->
</head>
<body ng-app="Facebook">
<div ng-controller="MainCtrl">
<%= Time.now.strftime("%m/%d/%Y") %><br>
<%= Time.now.strftime("%I:%M:%S") %>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="#">Titration</a>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="span12">
<ng-view></ng-view>
</div>
</div>
<footer>
<p>© IHSDigital 2014</p>
</footer>
</div>
</div>
</body>
</html>
资产/角度/ app.js
var app = angular.module("Facebook", [
"ngResource",
"Facebook.controllers",
"Facebook.services",
"ngRoute"
]);
app.config(function($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$routeProvider
.when("/facebook/index", { "views/facebook/index.html.erb", controller: "FacebookIndexCtrl" })
.when("/facebook/new", { templateUrl: "<%= asset_path('facebook/edit.html') %> ", controller: "FacebookEditCtrl" })
.when("/facebook/:id", { templateUrl: "<%= asset_path('facebook/show.html') %> ", controller: "FacebookShowCtrl" })
.when("/facebook/:id/edit", { templateUrl: "<%= asset_path('facebook/edit.html') %> ", controller: "FacebookEditCtrl" })
.otherwise({ redirectTo: "/facebook" });
});
app.config(function($httpProvider) {
$httpProvider.defaults.headers.common['X-CSRF-Token'] = $('meta[name=csrf-token]').attr('content');
});
的application.js
//
//= require angular
//= require angular-resource
//= require bootstrap
//= require ./angular/app
//= require_tree ./angular
我已尝试切换订单文件加载,检查50次拼写错误,并且我没有想法。
答案 0 :(得分:0)
您的代码
javascript_include_tag "application"
正在尝试加载文件application.js,因此您的角度js文件甚至没有加载到您的html页面中。
我不知道你的项目结构所以我会用
<script src="path/to/your/app.js" type="text/javascript"></script>
或
javascript_include_tag "app"