Reputation: 111
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
|   or  
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
Upvotes: 1
Views: 116
Reputation: 991
use "#task" and "#watchlist", your when is for html5mode, set using the $locationProvider.
Upvotes: 1
Reputation: 3726
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>
Upvotes: 0