Code Monkey home page Code Monkey logo

angular_rails_demo_app's Introduction

angular_rails_demo_app

To incorporate AngularJS into your own Rails app

Include the Jasmine gems in your gemfile

group :test, :development do
  gem 'jasmine'
  gem 'jasminerice'
  gem 'guard-jasmine'
end

And

$ bundle
$ rails g jasmine:install

This creates a couple files, including spec/javascripts/spec.js.coffee. Change that file to look like this:

#= require jquery
#= require angular-main
#= require angular-resource
#= require_tree ./

Include the AngularJS files:

Visit http://code.angularjs.org/ and choose a release. From the release page, copy the urls to the files you need and curl them into the appropriate directories. For example, for release 1.0.1:

$ curl http://code.angularjs.org/1.0.1/angular-1.0.1.js > vendor/assets/javascripts/angular-main.js
$ curl http://code.angularjs.org/1.0.1/angular-resource-1.0.1.js > vendor/assets/javascripts/angular-resource.js
$ curl http://code.angularjs.org/1.0.1/angular-mocks-1.0.1.js > spec/javascripts/helpers/angular-mocks.js

Then add angular.js and angular-resource.js to the asset pipeline. For example, in config/environments/production.rb:

config.assets.precompile += %w( angular.js )

And in app/assets/javascripts/, create a file angular.js:

//= require angular-main
//= require angular-resource

One could include angualr-main and angular-resource in application.js instead, but in an app with multiple, distinct Angular apps, I like to keep them completely distinct, and including a separate angular.js file in the asset pipeline means that AngularJS need only be downloaded once.

angular_rails_demo_app's People

Contributors

cade avatar

Watchers

Jim Cipriani avatar Jared A. Scheel avatar Nicholas Holland avatar James Cloos avatar  avatar Ben Gotow avatar John Horstman avatar Eddie Solis avatar Morley Bankston avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.