【发布时间】:2014-05-06 06:20:25
【问题描述】:
我正在学习如何使用 angularjs 路由和模板,我遇到了一个问题。我在 Gemfile 中添加了 gem,在 application.js 中添加了 //= require angular-rails-templates,并在我的主 angular.module 中添加了依赖项。一切似乎都很好,但模板没有正确呈现。
angular.module('authentication', ['authenticationModule','ngRoute','templates'])
.config(['$routeProvider',function($provider){
$provider
.when('/sign_in', { templateUrl: 'assets/signin.html', controller: 'redirectCtrl'})
.when('/sign_up', { templateUrl: 'assets/signup.html', controller: 'redirectCtrl1'})
}])
.controller('redirectCtrl', function($location) {
// $location.path('/sign_in')
})
.controller('redirectCtrl1', function($location) {
// $location.path('/sign_up')
})
这是我得到的,模板加载但有一些我不需要的额外内容http://postimg.org/image/iuhy9dflj/
这是我的注册页面中应该呈现的代码
<div ng-controller="authenticationCtrl">
<h1>Register</h1>
<div>
<div>
<div>Email: <input ng-model="email1" type="email"/></div>
<div>Password: <input type="password" ng-model="password1" /></div>
<div>Password Confirmation: <input type="password" ng-model="password2" /></div>
<button ng-click="register()" >Register</button>
</div>
</div>
</div>
我的 application.js 包含文件
//= require angular
//= require turbolinks
//= require_tree .
//= require angular-animate
//= require angular-resource
//= require devise-min
//= require angular-route.min
//= require angular-rails-templates
//= require_tree ../templates
【问题讨论】:
-
有完全相同的问题。如果我发现任何东西会更新。
标签: angularjs ruby-on-rails-4 angularjs-routing