我将 angularJs 与 Rails 一起使用,并使用以下布局:
!!! 5
%html(lang="en"){"ng-app"=>"MyApp"}
%head
%meta(charset="utf-8")
%meta(http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1")
%meta(name="viewport" content="width=device-width, initial-scale=1.0")
%title= content_for?(:title) ? yield(:title) : "MyApp"
= csrf_meta_tags
/ Le HTML5 shim, for IE6-8 support of HTML elements
/[if lt IE 9]
= javascript_include_tag "http://html5shim.googlecode.com/svn/trunk/html5.js"
/[if lt IE 8]
= stylesheet_link_tag "application-ie", :media => "all"
= stylesheet_link_tag "application", :media => "all"
%link(href="assets/apple-touch-icon-144x144.png" rel="apple-touch-icon-precomposed" sizes="144x144")
%link(href="assets/apple-touch-icon-114x114.png" rel="apple-touch-icon-precomposed" sizes="114x114")
%link(href="assets/apple-touch-icon-72x72.png" rel="apple-touch-icon-precomposed" sizes="72x72")
%link(href="assets/apple-touch-icon.png" rel="apple-touch-icon-precomposed")
%link(href="assets/favicon.ico" rel="shortcut icon")
%body
.container.content
.row-fluid.notifications
- if alert || notice
.span12
- if alert
.alert.alert-error= alert
- if notice
.alert.alert-info= notice
.row-fluid
.span12{"ng-view" => ""}
= yield
= javascript_include_tag "application"
= yield :javascript
我的问题是:当我对 rails url 执行操作时(例如:设计登录 url)Angular js 删除了我的产量的所有内容,因为没有 AngularJs 路由与当前路由匹配:
window.App = angular.module('MyApp', ['ngResource', 'ng-rails-csrf','ui.bootstrap']).config(['$routeProvider', '$locationProvider' ,
($routeProvider, $locationProvider) ->
#$locationProvider.hashPrefix('');
$locationProvider.html5Mode true
$routeProvider.when("/applications",
controller: 'ApplicationListCtrl'
templateUrl: '/applications.html?l=false'
)
])
我该如何管理?