npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

angular-cbc

v2.1.53

Published

Code Angular by conventions!

Downloads

32

Readme

Angular CBC - code angular by conventions!

The purpose of this module is to provide a quick way to start a new Angular 1.x application, using ES6 modules and its awesome syntax! You will use some conventions in order to maximize the result with less effort!

Usage

Install

Please be sure you have already run npm init command in your project!

Once you're sure you have a valid package.json file, run these commands in your shell:

  • npm i angular-cbc
  • ./node_modules/.bin/angular-cbc install

Concepts your should know

This project uses Angular UI Router, an awesome Angular module which provides states instead of routes and a lot of possibilities. Take a look if you don't know it!

Effects

Something happened... Your project now has a new structure, with a js folder, a css folder, an index.html file, a webpack.config.js file and a pages folder.

js folder

In this folder you will have:

  • app.js, if you know Angular you know what's that. But there is just one difference: basically you do not have to touch this file... maybe never! :)
  • routes.js, this file contains an array of routes that will be automatically used in this project! Just provide a name for the route, a matching URL and the controller used in this route! That's it!

The first convention Each routes/state uses a template called as the route itself. So, if you provide a named state like home, the file under pages/home.html will be rendered! Another example with nested states? Let's imagine we are under a state called home.list... well, it's assumed the template to be used is pages/home.list.html!

  • config.js, sets the routes and some other initial configs
  • directives.js, this file is used to import all the directives you will write. Don't forget to do not edit this file! It's autogenerated!

The second convention In order to write autoloading directives, you must to write them inside the directives folder, creating a sub folder with the same name of the .js file you will create... An example: We are going to create a navbar directive; let's create a navbar folder under the directives one, and a navbar.js file inside the navbar folder Note: Don't forget to export the function itself, according to the new ES6 module syntax

export default function navbar() {
    return {
        link: ...
        template: ...
    }
}

js/controllers folder

Put your controllers in this folder, export the class by default and import it inside your routes file, creating a controller entry inside any object

From routes.js

    import HomeController from './controllers/HomeController'
    ...
    [
        name: 'home',
        url: '/home',
        controller: HomeController
    ]
    ...

The third convention You must extend the BaseController in any controller your create, in this way you can use the controller name to refer to its scope inside your html templates. Example: We create an HomeController, which extends BaseController. We set this controller in the routes file for the home state. We set in the HomeController constructor two fields:

    export default class HomeController extends BaseController{
        constructor($scope){
            super($scope)
            this.name = 'Test'
            this.surname = 'McTest'
            }
        }

We want to show data in pages/home.html, and we can refer to the scope using home.name and home.surname! So basically the controller name withouth the controller suffix by convention!

TIP: you can refer to the controller scope inside the html template also using the dollar sign... Just a shortcut so!

    <div>
        {{home.name}} is equivalent to
        {{$.name}}
    </div>
    <div>
        {{home.surname}} is equivalent to
        {{$.surname}}
    </div>

Run

To run the project, just type npm start in your terminal and visit http://localhost:8080 from your browser

Contributors Guide

I would be happy if anyone will contribute with coding or just with ideas! The Git repository is this one

App folder

The app folder is the folder that will be downloaded by the module, in order to copy files and directory locally for the user who run the install command.

You can clone the repo and treat the app folder as an Angular app. Anything put under this folder will be copied into the user project, unless you do not set a filter in the dirCopy function in index.js (~ line 22)