pitr / angular-rails-templates

Use your angular templates with rails' asset pipeline
https://rubygems.org/gems/angular-rails-templates
MIT License
566 stars 169 forks source link

Templates are not rendering #132

Closed txssseal closed 8 years ago

txssseal commented 8 years ago

My template will not render, below is my setup, not sure if its something I am doing, or if templates has a bug. Also i have my angular-rails-templates pointed at the master branch on github, where the sprockets bug has been fixed for sprockets 3.0.

views/printers/orders_index.html.erb

<div ng-app="printers"> 
  <div ui-view></div>
</div>

assets/javascripts/printers/config.js

(function() {
'use strict'
  angular.module('printers.controller', [])
  angular
    .module('printers', 
      ['ngAnimate',
       'ui.router',
       'templates',
       'ngResource', 
       'printers.controller',
       'orders.factories'
      ])
    .config(function ($stateProvider, $urlRouterProvider, $locationProvider) {
      /* Routes and States*/
      $stateProvider
          .state('printers.orders.index', {
              url: '/printer_orders_index',
              templateUrl: 'orders_index.html',
              controller: 'PrintersController'
          })
      // default fall back route
      $urlRouterProvider.otherwise('printers_orders_index')
    })
})()

assets/templates/orders_index.html

<h1>Meow</h1>

The template above will not render. It just stays in the regular rails view. Is there something im doing wrong with the templates, or is this a bug?

pitr commented 8 years ago

Are there any errors in the console? Is the template loaded successfully as /assets/orders_index.js BEFORE your application code?

PS I released v1.0.0 yesterday, so you don't need to point at master branch anymore

txssseal commented 8 years ago

no errors in the console :-1:, it looks as if it is loading Started GET "/assets/templates/orders_index.self-4c215f54253dd51a2b90b85dd70ee56db1426b03f2ac01102fb3e6922f399bb3.js?body=1" for 127.0.0.1 at 2016-02-11 10:45:18 -0600, and its loaded before my application code. Ill post a gist.

https://gist.github.com/txssseal/f1b4397900233e648d20

Ya, i updated for version 1.0.0, thank you for that! Also angular version 1.4.9, and rails 4.2.5.

pitr commented 8 years ago

One thing I noticed is that request log doesn't show a few things:

  1. angular.js itself, though I assume you are loading it from CDN
  2. angular-rails-templates.js (see step 2 in the README)
txssseal commented 8 years ago

@pitr ya they are there. Angular is being served filesystem using bower. And I have the angular-rails-templates include in the application.js.

pitr commented 8 years ago

Hmm, try replacing temporarily templateUrl: 'orders_index.html' with template: '<h1>Meow</h1>' and see if it works. If yes, then the problem is somewhere in this gem, otherwise the problem is elsewhere.

txssseal commented 8 years ago

wasnt a problem with the gem, was a problem with how I was naming my states.