generate a angular distribution for your rails app
First start by adding this gem to your Gemfile:
gem "rails_angular_generator", github: 'Tolia/rails_angular_generator'
And then execute
bundle
> rails g
Angular:
- angular:assets
- angular:controller
- angular:directive
- angular:factory
- angular:filter
- angular:service
> rails g angular:assets
identical app/assets/javascripts/ng_manifest.js
identical app/assets/javascripts/ng/init.coffee
identical app/assets/javascripts/ng/settings.coffee
identical app/assets/javascripts/ng/controllers/.keep
identical app/assets/javascripts/ng/directives/.keep
identical app/assets/javascripts/ng/factories/.keep
identical app/assets/javascripts/ng/filters/.keep
identical app/assets/javascripts/ng/services/.keep
identical app/assets/html/.keep
create config/initializers/slim_assets.rb
> rails g angular:controller ControllerName
create app/assets/javascripts/ng/controllers/controller_name.coffee
> cat app/assets/javascripts/ng/controllers/controller_name.coffee
@APP.controller.ControllerName = [
"$scope"
"$attrs"
($scope, $attrs) ->
]
> rails g angular:directive DirectiveName
create app/assets/javascripts/ng/directives/directive_name.coffee
create app/assets/html/directive_name.html.slim
> cat app/assets/javascripts/ng/directives/directive_name.coffee.erb
@APP.directive.DirectiveName = [
() ->
restrict: "C" # "ACE"
# transclude: true
replace: true
templateUrl: '<%= asset_path "directive_name.html" %>'
# scope:
# DirectiveName: '=DirectiveName'
# controller: [
# "$scope"
# "$attrs"
# ($scope, $attrs) ->
# ]
link: ($scope, $element, $attrs) ->
]
> cat app/assets/html/directive_name.html.slim
.directive_name
| text in DirectiveName directive
> rails g angular:factory '$factoryName'
create app/assets/javascripts/ng/factories/factory_name.coffee
> cat app/assets/javascripts/ng/factories/factory_name.coffee
@APP.factory.$factoryName = [
() ->
$factoryName = {}
]
> rails g angular:filter filter_name
create app/assets/javascripts/ng/filters/filter_name.coffee
> cat app/assets/javascripts/ng/filters/filter_name.coffee
@APP.filter.FilterName = [
->
FilterName = (data) ->
data
]
> rails g angular:service Service_Name
create app/assets/javascripts/ng/services/service_name.coffee
> cat app/assets/javascripts/ng/services/service_name.coffee
@APP.service.ServiceName = [
() ->
ServiceName = {}
]