Skip to content

renearias/imperyaweb

Repository files navigation

Imperya App Angular 2.0 Seed version

install Sing Seed version with npm

npm install

install TypeScript typings

npm run typings-install

start the server

npm start go to http://0.0.0.0:3000 or http://localhost:3000 in your browser

Table of Contents

File Structure

We use the component approach in our starter. This is the new standard for developing Angular apps and a great way to ensure maintainable code by encapsulation of our behavior logic. A component is basically a self contained app usually in a single file or a folder with each concern as a file: style, template, specs, e2e, and component class. Here's how it looks:

sing-app/
  |───src/
  |   │   app.html                                       
  |   │   app.ts                                         * Here we create root routing and render all views
  |   │   index.html                                     * Index.html: where we generate our index page
  |   │   main.ts                                        * Our entry file for our browser environment
  |   │   polyfills.ts                                   * Our polyfills file
  |   │
  |   ├───app/
  |   │   ├───another                                    * Simple Another page
  |   │   │       another.html
  |   │   │       another.ts
  |   │   │
  |   │   ├───core/                                      * Full basic layout of template, services and pipes are here
  |   │   │   │   config.ts
  |   │   │   │   core.html
  |   │   │   │   core.ts
  |   │   │   │
  |   │   │   ├───chat-sidebar/                          * ChatSidebar component
  |   │   │   │   │   chat-service.ts
  |   │   │   │   │   chat-sidebar.html
  |   │   │   │   │   chat-sidebar.ts
  |   │   │   │   │
  |   │   │   │   └───chat-message/                      * ChatMessage component
  |   │   │   │           chat-message.html
  |   │   │   │           chat-message.ts
  |   │   │   │
  |   │   │   ├───navbar/                                * Navbar component
  |   │   │   │       navbar.html
  |   │   │   │       navbar.ts
  |   │   │   │
  |   │   │   ├───notifications/                         * Notifications component
  |   │   │   │       notification-load.ts                 * NotificationsLoad directive
  |   │   │   │       notifications.html
  |   │   │   │       notifications.ts
  |   │   │   │
  |   │   │   ├───pipes/                                 * Folder for angular2 custom pipes
  |   │   │   │       pipe.ts
  |   │   │   │
  |   │   │   ├───sidebar/                               * Sidebar component
  |   │   │   │       sidebar.html
  |   │   │   │       sidebar.ts
  |   │   │   │
  |   │   │   │
  |   │   │   └───widget/                                * Widget directive
  |   │   │           widget.ts
  |   │   │
  |   │   ├───dashboard/                                 * Simple Dashboard page
  |   │   │       dashboard.html
  |   │   │       dashboard.ts
  |   │   │
  |   │   ├───error/                                     * Error page
  |   │   │       error.html
  |   │   │       error.ts
  |   │   │
  |   │   └───login/                                     * Login page
  |   │           login.html
  |   │           login.ts
  |   │
  |   ├───assets/
  |   │   ├───demo/
  |   │   │   └───notifications/                         * Templates for notification-dropdown
  |   │   │
  |   │   ├───fonts/                                     * All fonts
  |   │   │   ├───font-awesome/
  |   │   │   ├───glyphicons/
  |   │   │   └───google/
  |   │   │
  |   │   └───images/                                    * JPEG, PNG files
  |   │
  |   └───scss/                                          * All styles for layout
  |
  |──tsconfig.json                                       * Config that webpack uses for typescript
  |──typings.json                                        * Our typings manager
  |──package.json                                        * What npm uses to manage it's dependencies
  |
  |──webpack.config.js                                   * Our development webpack config
  └──webpack.prod.config.js                              * Our production webpack config
  
  

Getting Started

Dependencies

What you need to run this app:

  • node and npm (brew install node)
  • Ensure you're running the latest versions Node v4.1.x+ and NPM 2.14.x+

Once you have those, you should install these globals with npm install --global:

  • webpack (npm install --global webpack)
  • webpack-dev-server (npm install --global webpack-dev-server)
  • karma (npm install --global karma-cli)
  • protractor (npm install --global protractor)
  • typings (npm install --global typings)
  • typescript (npm install --global typescript)

Running the app

After you have installed all dependencies you can now run the app. Run npm run server to start a local server using webpack-dev-server which will watch, build (in-memory), and reload for you. The port will be displayed to you as http://0.0.0.0:3000 (or if you prefer IPv6, if you're using express server, then it's http://[::1]:3000/).

server

# development
npm run server
# production
npm run build:prod
npm run server:prod

Other commands

build files

# development
npm run build:dev
# production
npm run build:prod

watch and build files

npm run watch

run lint

npm run lint

TypeScript

To take full advantage of TypeScript with autocomplete you would have to install it globally and use an editor with the correct TypeScript plugins.

Use latest TypeScript compiler

TypeScript 1.7.x includes everything you need. Make sure to upgrade, even if you installed TypeScript previously.

npm install --global typescript

Use a TypeScript-aware editor

We have good experience using these editors:

Typings

When you include a module that doesn't include Type Definitions inside of the module you need to include external Type Definitions with Typings

Use latest Typings module

npm install --global typings

Custom Type Definitions

When including 3rd party modules you also need to include the type definition for the module if they don't provide one within the module. You can try to install it with typings

typings install node --save

If you can't find the type definition in the registry we can make an ambient definition in this file for now. For example

declare module "my-module" {
  export function doesSomething(value: string): string;
}

If you're prototying and you will fix the types later you can also declare it as type any

declare var assert: any;

If you're importing a module that uses Node.js modules which are CommonJS you need to import as

import * as _ from 'lodash';

You can include your type definitions in this file until you create one for the typings registry see typings/registry

Frequently asked questions

  • What's the current browser support for Angular 2 Beta?
  • Why is my service, aka provider, is not injecting parameter correctly?
    • Please use @Injectable() for your service for typescript to correctly attach the metadata (this is a TypeScript problem)
  • How do I start the app when I get EACCES and EADDRINUSE errors?
    • The EADDRINUSE error means the port 3000 is currently being used and EACCES is lack of permission for webpack to build files to ./dist/
  • What are the naming conventions for Angular 2?
  • please see issue #185 and PR 196
  • How do I async load a component?
  • the component must have .async.ts and require using webpack loader: () => require('./about/about')('About')

Support, Questions, or Feedback

Contact us anytime for anything about this repo or Angular 2


enjoy

##Flatlogic

Looking for Angular development or consulting services? [email protected]

License

© 2016 Flatlogic LLC, All Rights Reserved

About

Imperya Web App

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •