我正在按照本教程制作一个带 Angular Rails 应用程序,并已完成本节:https://thinkster.io/angular-rails/#integrating-the-front-end-with-the-asset-pipeline-moving-angular-templates-into-the-asset-pipeline-and-structuring-the-javascripts-folder
我的页面上没有显示任何内容,尽管它说
< !-- uiView: undefined -->
这是 HTML:
<html>
<head>
<title>TestApp</title>
<%= stylesheet_link_tag 'application', media: 'all' %>
<%= javascript_include_tag 'application' %>
<%= csrf_meta_tags %>
</head>
<body ng-app="sfslaps">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<ui-view></ui-view>
</div>
</div>
</body>
</html>
</html>
还有 Angular :
angular.module('sfslaps', ['ui.router', 'templates'])
.config([
'$stateProvider',
'$urlRouterProvider',
function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('home', {
url: '/home',
templateUrl: 'home/_home.html',
controller: 'MainCtrl'
})
.state('posts', {
url: '/posts/{id}',
templateUrl: 'posts/_post.html',
controller: 'PostsCtrl'
});
$urlRouterProvider.otherwise('home');
}]);
是什么导致它这样说而不显示我的任何 UI View ?所有 HTML 都在 ui-view 中,但它事先表示未定义。
最佳答案
不知道你有没有想过... 据我所知,您正在学习本教程:https://thinkster.io/angular-rails/
您做的一切都正确,但是当您将模板放在“_home.html”文件中时,您必须删除代码周围的“script”标签。否则,您基本上是在包含内联模板而不是 HTML 代码。
关于javascript - 带有 Angular 的 Rails - uiView 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28712125/