I have a Rails app with AngularJS in some of the views. Whenever I click a link that brings me to a page, say /certifications
I see this
Then when I reload the page or request it by pressing enter in the url bar, it works and shows this
Is there a difference in how these two pages are being reloaded that is screwing up AngularJS. Do I need to user and angular router or something? I have put the code of the view and controller below. Thanks for the help!
Controller:
@aquaticsApp = angular.module 'aquaticsApp',
['ngResource', 'aquaticsAppFilters']
@aquaticsApp.controller 'CertsCtrl', ['$scope', 'Certs',
@CertsCtrl = ($scope, Certs) ->
$scope.formatDate = (dateString) ->
d = new Date(dateString)
curr_month = d.getMonth() + 1
curr_date = d.getDate()
curr_year = d.getFullYear()
"#{curr_month}/#{curr_date}/#{curr_year}"
$scope.sorter =
value: 'firstName'
Certs.get (data) ->
$scope.certNames = data.certification_names
$scope.users = data.users
]
View:
<div ng-app='aquaticsApp' class='table-responsive'>
<table ng-controller='CertsCtrl' class='table table-hover table-condensed'>
<thead>
<tr>
<th ng-click='sorter.value="lastName"'>Last Name</th>
<th ng-click='sorter.value="firstName"'>First Name</th>
<th ng-click='sorter.value="location"'>Location</th>
<th ng-repeat='certName in certNames' ng-click='sorter.value=certName.name'>
{{certName.name}}
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat='userData in users | orderBy:sorter.value'>
<td>{{userData.lastName}}</td>
<td>{{userData.firstName}}</td>
<td>{{userData.location}}</td>
<td ng-repeat='certName in certNames' class='{{userData[certName.name + "class"]}}'>
{{formatDate(userData[certName.name])}}
</td>
</td>
</tr>
</tbody>
</table>
</div>