Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

In my web app, when I go to one of my url, angularjs returns me haml template as a plain text. But if I go to my root url it works fine. I use Rails 3.2.13, AngularJS 1.1.4, Haml for views.

This is my app/views/layouts/application.html.haml

!!! 5
%html{'ng-app' => 'myproject'}
  %head
    %title MyProject
    = favicon_link_tag
    = stylesheet_link_tag 'application'
    = javascript_include_tag 'application'
    = csrf_meta_tag

    %body
      .main-background
      .app{'ng-view' => ''}
        = yield

This is my app/assets/javascripts/main.js.coffee

@app = angular.module('myproject', [])

This is my app/assets/javascripts/routes.js.coffee

app.config ['$routeProvider', '$locationProvider', ($routeProvider, $locationProvider) ->

  $routeProvider
  .when '/',
    templateUrl: '/assets/signin/index.haml',
    controller: 'SignInController'

  .when '/signup/:code',
    templateUrl: '/assets/signup/index.haml',
    controller: 'SignUpController',

]

I have 2 controllers in app/asssets/javascripts/controllers/ respectively. They both are emty. I also use html5 push state, lik this(push_state.js.coffee)

app.config ($locationProvider) ->
  $locationProvider.html5Mode true

And, I have views, in app/assets/templates, whith path, that I wrote in templateUrl.

My problem is, when I go to '/', angularjs render my view fine, but, when I go to the second url, it returns me a plain text in span tag, with haml template inside it. I tried to use only one when statement with the second template and it was the same result. And, the question is what should I do to render my second view properly ?

share|improve this question

1 Answer

up vote 0 down vote accepted

I found a solution. It strange, but when I do some edit in my templates, and revert then back, after that all templates render properly. In both cases, before edit and after, templates have the same markup.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.