Skip to content
Joshua Nussbaum edited this page Jan 24, 2015 · 1 revision

Define a route

Edit your app/assets/javascripts/sprangular/extraRoutes.coffee and add the route. For example:

angular.module('MyApp').config ($routeProvider) ->

  $routeProvider
    .when '/about',
      template: '<h1>#1 Internet Site</h1>'
    .when '/team',
      controller: 'TeamCtrl',
      templateUrl: 'team/index.html'

Define a controller

# in app/assets/sprangular/controllers/team.coffee
angular.module('MyApp').controller 'TeamCtrl', ($scope) ->
  $scope.members = [
     {name: "Josh", title: "Developer"}
     {name: "Bryan", title: "Developer"}
  ]

Define the view

// in app/assets/templates/team/index.html.slim
ul
  li(ng-repeat='member in members')
    span.name(ng-bind='member.name')
    span.occupation(ng-bind='member.title')

Clone this wiki locally