Join the Stack Overflow Community
Stack Overflow is a community of 6.8 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I'm building a toy app in Angular/Rails and I have most of the angular ui routing working, but it doesnt seem to display the template. I know the controller is being loaded because I put a debugger and it freezes in the chrome dev tools.

Link to github branch

EDIT: Its probably because the templateUrl specified isnt a valid route. It's injected the root html file into itself and requiring angular multiple times. Absolute paths don't work either. Still no solution.

Here's some of my code:

I also know the redirect routing works because I've tested it in local host.

angular.module('SwoleMetrics', [
        'ui.router',
        'templates'
    ])
    .config(function ($stateProvider, $urlRouterProvider, $locationProvider) {
      /**
       * Routes and States
       */
      $stateProvider
          .state('dashboard', {
              url: '/dashboard',
              templateUrl: 'dashboard.html',
              controller: 'DashboardCtrl'
          });

      // default fall back route
      $urlRouterProvider.otherwise('/dashboard');

      // enable HTML5 Mode for SEO
      $locationProvider.html5Mode(true);
    });

Here's the controller:

angular.module('SwoleMetrics')
    .controller('DashboardCtrl', function ($scope) {
        $scope.things = ['Angular', 'Rails 4.1', 'UI Router', 'Together!!'];
    });

And finally the template:

<div class="container">
    <h1>The Home View!</h1>
    <ul>
        <li ng-repeat="thing in things">{{thing}}</li>
    </ul>
</div>

It goes inside this tag but I dont think this is the issue:

<div class="main-view-container" ui-view></div>

I'm using angular-ui-templates 1.4.0 if that helps.

share|improve this question
    
Are you getting any console errors?Is the path correct? – Olavi Sau Nov 7 '15 at 0:18
1  
No console errors, path is correct. (Ive actually moved the templates everywhere around and tested but no success). Just template isnt loading. – Jeff Nov 7 '15 at 0:20
    
where is your dashboard.html situated? You should provide path from your app root. So if i have controller in /app/controllers/controller1.js and templates in /app/templates/dashboard.html it should be: templateUrl: '/app/templates/dashboard.html' – Marek Pavelek Nov 7 '15 at 0:31
    
app.run(($rootScope) => { $rootScope.$on("$stateChangeError", console.log.bind(console)); }); add this and show what results you got – Olavi Sau Nov 7 '15 at 0:33
    
@MarekPavelek, I just tried it and it didnt work. Also I'm using angular-ui-templates so it uses templates as the root directory for my templatesUrl. – Jeff Nov 7 '15 at 0:36

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.