【发布时间】:2015-09-04 04:49:42
【问题描述】:
您好,我正在尝试在我的 rails 应用程序中包含 Angular,但我得到了一个空白的 html 这是我的代码
app/views/index.html.erb
<body>
<div ng-controller="MainController">
<ng-view></ng-view>
</div>
<script type="text/ng-template" id="view.html">
<div ng-controller="MainController">This is the view with some data here: {{ somedata }}</div>
</script>
</body>
assets/javascript/static.js
var app = angular.module('app', ['ngRoute']);
app.controller('MainController', function($scope) {
$scope.somedata = "This is some data!"
});
app.config(function($routeProvider) {
$routeProvider
.when('/', {templateUrl: 'view.html'})
})
应用程序.js
//= require angular-resource
//= require angular
//= require_tree .
routes.rb
Rails.application.routes.draw do
root 'static#index'
get '*path' => 'static#index'
end
现在,每当我访问服务器时,我都会看到一个空白页面。没有错误。我正在使用“angularjs-rails”gem,它似乎工作正常,直到我添加了角度路线。请指出错误在哪里。
【问题讨论】:
标签: javascript ruby-on-rails ruby angularjs