1

In my application rails with angular, i create directory /app/assets/javascripts/angular/templates to create my views.

My route.js.coffe

app.config ($routeProvider) ->
  $routeProvider
  .when('/task', {
    templateUrl: 'templates/task/index.html'
    controller: 'TaskCtrl'
  })

My index.slim

.container
  h2
    |What would you like to do?

  a href="#/watchlist"
    | Watchlist
  | &nbsp or &nbsp
  a href="#/task"
    | Task

  div class="row" ng-view=""

When i click the link "Task" nothing happens. I see the following message on the console:

Started GET "/templates/task/index.html" for 192.168.1.106 at 2014-08-29 08:49:17 -0300 ActionController::RoutingError (No route matches [GET] "/templates/task/index.html"):

My index.html:

<div ng-controller="TaskCtrl">
  <h2>teste</h2>
</div>

and my route.rb

Rails.application.routes.draw do

  get 'home/index'

  scope :api, defaults: {format: :json} do
    resources :tasks
    resources :stocks
  end

  root 'home#index'

end
1
  • How are you binding the app to your application? Commented Aug 29, 2014 at 12:26

2 Answers 2

1

use "#task" and "#watchlist", your when is for html5mode, set using the $locationProvider.

Sign up to request clarification or add additional context in comments.

1 Comment

i tried html5mode before, when it was false and true, i just can't remember using '#/' in the link.
0

Make sure you are binding the application itself to the view.

You can bootstrap it to the document

angular.bootstrap(document, ['appname']); 

Or bind it someone on your index

<body ng-app="appName">

</body>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.