GithubHelp home page GithubHelp logo

angular-generators's Introduction

Angular Generators

This generator will provide you the base structure Angular on your rails projects. It has init and scaffold generating scripts.

Setup

Add the gem to your Gemfile.

gem "angular-generators", group: :development

Initially you have run the following command to

rails g angular:init

The above initialize command will initialize the Angular directory structure like as follows,

For example your application name is depot,

app/assets/javascripts/angular/YOUR_APP_NAMEApp.js.coffee
app/assets/javascripts/angular/controllers.js.coffee
app/assets/javascripts/angular/services.js.coffee
app/assets/javascripts/angular/directives.js.coffee
app/assets/javascripts/angular/filters.js.coffee
app/assets/javascripts/angular/services/routes.js.coffee
app/assets/javascripts/angular/controllers/application_controller.js.coffee

After the initial setup paste the following code on your application

app/views/layouts/application.html.erb

<html>

Change to

<html ng-app="YOUR_APP_NAMEApp" ng-controller="ApplicationController" ng-init="initialize()">

Add angularjs google api to your application javascript tag like as follows,

<%= javascript_include_tag "https://ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js" %>
<%= javascript_include_tag "https://ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular-sanitize.min.js" %>

Generate module

Run this generator to include modules to your angular section,

rails g angular:scaffold Post

        (OR)

rails g angular:scaffold post

It generates the controller and service module and update the routes file. Here are the example files list,

app/assets/javascripts/angular/controllers/posts_controller.js.coffee
app/assets/javascripts/angular/services/models/post.js.coffee
app/assets/javascripts/angular/services/routes.js.coffee

So add the controller tag to your corresponding posts view file.

Ex,

<div ng-controller="PostsController" ng-init="initialize()">
<p id="notice"><%= notice %></p>

<h1>Listing Posts</h1>

Gon Usage

For connecting your rails controller to javascripts you may try this [Gon] (https://github.com/gazay/gon) gem.

Sample Application

Sample Application Scaffolding.

Sample App Demo URL Scaffolding

Wiki

Routes will covered ASAP.

Contributing

If you want to contribute to this project, you can download it from Github repository, I develop this using Ruby 2.1.2. I think it should work with later vestions too.

Issue

It you found any issue, pease let me know.

angular-generators's People

Contributors

demonchand avatar

Watchers

 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.