-
Notifications
You must be signed in to change notification settings - Fork 23
Sprangular extensions gems
Joshua Nussbaum edited this page Feb 21, 2015
·
16 revisions
To see a fully working extension, check out the sprangular_static_content gem.
This is a tutorial for creating a Sprangular extension. We will create a module called Sprangular.Example, with one route /test which will use a controller named TestCtrl.
gem install sprangular_clisprangular extension example
cd sprangular_exampleIt can depend on Sprangular if needed:
# in app/assets/javascripts/sprangular/example/module.coffee
angular.module('Sprangular.Example', ['Sprangular'])# in app/assets/javascripts/sprangular/example/routes.coffee
angular.module('Sprangular.Example')
.config ($routeProvider) ->
$routeProvider.when '/test',
controller: 'TestCtrl'
templateUrl: 'test/index.html'# in app/assets/javascripts/sprangular/example/controllers/test.coffee
angular.module('Sprangular.Example').controller 'TestCtrl', ($scope) ->
$scope.message = "Hello World!"// app/assets/templates/test/index.html.slim
h1(ng-bind="message")This manifest js will be used by the host app to require all the js at once.
// in app/assets/javscripts/sprangular/example.js
//= require example/module
//= require example/routes
//= require_tree example/controllersgem 'sprangular_example', github: 'me/sprangular_example'// in application.js
...
//= require sprangular
//= require sprangular/example
...# in app/assets/javascripts/sprangular/host.coffee
angular.module 'YourApp', ['Sprangular', 'Sprangular.Example']Visit #!/test to see the results.