All Projects → owen-it → ng-loader

owen-it / ng-loader

Licence: MIT License
Webpack loader for AngularJs components

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to ng-loader

Angular4-seed
Angular 4 Seed for Angular Forms
Stars: ✭ 37 (+32.14%)
Mutual labels:  angularjs, angular-components
Cloudinary angular
Cloudinary Angular client library
Stars: ✭ 305 (+989.29%)
Mutual labels:  angularjs, angular-components
Angular-Firebase-Sortable-Table
Angular Firebase Sortable Table is a module that makes tables creation with firebase an easy task.
Stars: ✭ 28 (+0%)
Mutual labels:  angularjs, angular-components
Fef
The Front End Framework is a Thomson Reuters Tax and Accounting project to create a re-usable library for creating rich HTML based applications. The end goal is to assemble the publicly available libraries into a reference application with documentation along with best practice architecture.
Stars: ✭ 96 (+242.86%)
Mutual labels:  angularjs, angular-components
Ngx Quill Editor
🍡@quilljs editor component for @angular
Stars: ✭ 234 (+735.71%)
Mutual labels:  angularjs, angular-components
Angular Async Loader
Load modules and components asynchronously for angular 1.x application.
Stars: ✭ 137 (+389.29%)
Mutual labels:  angularjs, loader
Angular Prest
pREST component for Angular
Stars: ✭ 16 (-42.86%)
Mutual labels:  angularjs, angular-components
spinners-angular
Lightweight SVG/CSS spinners for Angular
Stars: ✭ 21 (-25%)
Mutual labels:  loader, angular-components
angular2-cookie-law
Angular2+ component that provides a banner to inform users about cookie law
Stars: ✭ 38 (+35.71%)
Mutual labels:  angularjs, angular-components
gd-obj
Obj file parser for Godot
Stars: ✭ 32 (+14.29%)
Mutual labels:  loader
react-awesome-loaders
🚀 High quality, super responsive and completely customisable Loading Animations to insert into your website with single line of code.
Stars: ✭ 146 (+421.43%)
Mutual labels:  loader
otc
Onetap Crack Loader - Official ReHost
Stars: ✭ 46 (+64.29%)
Mutual labels:  loader
angular-google-picker
An Angular directive that interact with Google Picker API
Stars: ✭ 78 (+178.57%)
Mutual labels:  angularjs
wp-testing
WordPress testing plugin
Stars: ✭ 12 (-57.14%)
Mutual labels:  angularjs
stream2segment
A Python project to download, process and visualize medium-to-massive amount of seismic waveforms and metadata
Stars: ✭ 18 (-35.71%)
Mutual labels:  angularjs
material-circular-loader
Material Circular Loader in SCSS like a boss. Demo: http://codepen.io/YuRen/details/KdKKax
Stars: ✭ 13 (-53.57%)
Mutual labels:  loader
ng-scrollable
Superamazing scrollbars for AngularJS
Stars: ✭ 58 (+107.14%)
Mutual labels:  angularjs
ionic4-angular6-crud-example
Building CRUD Mobile App using Ionic 4, Angular 6 and Cordova
Stars: ✭ 50 (+78.57%)
Mutual labels:  angularjs
assetter
Assets manager for PHP. Allow manage CSS and JS files in website and its dependencies. Also allows refresh cache in browsers by adding revisions of loaded files. Builtin plugins to compile SASS and/or LESS styles to CSS just-in-time.
Stars: ✭ 14 (-50%)
Mutual labels:  loader
asana-webhooks-manager
Asana Webhooks Manager (AWM) is a free and open source management and event handling server, written in JavaScript (NodeJS, Angular) for Asana's webhooks API. Use AWM to manage webhooks subscriptions and accept event payloads from Asana in real-time. Want to create your own Asana Dashboard? Consider AWM as your starting point!
Stars: ✭ 23 (-17.86%)
Mutual labels:  angularjs

ng-loader Downloads Version License

ng-loader is a loader for Webpack that can transform *.ng files into AngularJs Components.

Note: [email protected] had a different purpose than version 2.*, it was currently migrated to ng-module-loader.

What is Webpack?

webpack is a tool to build JavaScript modules in your application. To start using webpack from its cli or api, follow the Installation instructions. webpack simplifies your workflow by quickly constructing a dependency graph of your application and bundling them in the right order. webpack can be configured to customise optimisations to your code, to split vendor/css/js code for production, run a development server that hot-reloads your code without page refresh and many such cool features. Learn more about why you should use webpack.

Understanding Loaders

Loaders are transformations that are applied on a resource file of your application. They are functions (running in Node.js) that take the source of a resource file as the parameter and return the new source. Learn more about loaders.

Install

npm install --save-dev ng-loader

Usage

Use the loader either via your Webpack config.

Via webpack config (recommended)

module.exports = {
  module: {
    rules: [
      {
        test: /\.ng$/,
        use: [ 'ng-loader' ]
      }
    ]
  }
}

Passing parameters:

You can also configure ng-loader and the sub-loaders for your components. Bellow is the default configuration.

{
  test: /\.ng$/,
  use: [
    {
      loader: 'ng-loader'
      options: {
        hotReload: true,
        loaders: {
          html: [
            'html-loader'
          ],
          js: [
            {
              loader: 'babel-loader',
              options: {
                presets: ['es2015'],
                plugins: ['transform-runtime'],
                comments: false
              }
            }
          ],
          sass: [
            'style-loader',
            'css-loader'
          ]
        }
      }
    }
  ]
}

Angular Component

In AngularJS, a Component is a special kind of directive that uses a simpler configuration which is suitable for a component-based application structure.

This makes it easier to write an app in a way that's similar to using Web Components or using the new Angular's style of application architecture.

Advantages of Components:

  • simpler configuration than plain directives
  • promote sane defaults and best practices
  • optimized for component-based architecture
  • writing component directives will make it easier to upgrade to Angular

You can see the full documentation here.

The *.ng file

A *.ng file is a custom file format that uses HTML-like syntax to describe a angular component. Each *.ng file consists of three types of top-level language blocks: <template>, <script> and <style>:

<!-- ./src/components/my-component.ng -->
<template>
    <h1 class="ui header">
        {{ $ctrl.description }}
    </h1>
</template>

<script>
    export default {
        controller(){
            this.description = 'A AngularJs Component!'
        }
    }
</script>

<style lang="sass">
    @import '~semantic-ui';
</style>

ng-loader will parse the file, extract each language block, pipe them through other loaders if necessary, and finally assemble them back into a CommonJS module whose module.exports is a AngularJs Component options object.

Language Blocks

<template>

  • Default language: html.

  • Each *.ng file can contain at most one <template> block at a time.

  • Contents will be extracted as a string and used as the template option for the compiled AngularJs Component.

<script>

  • Default language: js (ES2015 is supported automatically if babel-loader or buble-loader is detected).

  • Each *.ng file can contain at most one <script> block at a time.

  • The script is executed in a CommonJS like environment (just like a normal .js module bundled via Webpack), which means you can require() other dependencies. And with ES2015 support, you can also use the import and export syntax.

    // tag script inside ng file ./src/components/my-component.ng
    exports default {
        controller () {
            this.description = 'A AngularJs Component';
        }
    };

Registering your component:

import * as angular from 'angular';

import myComponent from './components/my-component.ng';

angular.module('app', []).component('myComponent', myComponent);

You can also return an array with the component data. The first item represents the component name and the second component options.

    // tag script inside ng file ./src/components/my-component.ng
    exports default ['myComponent', {
        controller: () => {
            this.description = 'AngularJs';
        }
    }];

and register as follows

import * as angular from 'angular';

import myComponent from './components/my-component.ng';

angular.module('app', []).component.apply(angular, myComponent);

// ES2015
// .component(...myComponent)

<style>

  • Default Language: css;
  • Multiple <style> tags are supported in a single *.ng file;
  • By default, contents will be extracted and dynamically inserted into the document's <head> as an actual <style> tag using style-loader;

The component

<my-component></my-component>

Hot Reload

This feature is provided by ng-hot-reload-api

Syntax Highlighting

You can treat *.ng files as HTML in your editor.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].