├── .travis.yml
├── .gitignore
├── .jshintrc
├── .editorconfig
├── bower.json
├── package.json
├── LICENSE
├── gulpfile.js
├── dist
├── angular-component.min.js
└── angular-component.js
├── README.md
└── src
└── angular-component.js
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - "0.10"
4 | - "0.11"
5 | before_script:
6 | - npm install -g gulp
7 | script: gulp
8 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Node
2 | node_modules
3 |
4 | ## OS X
5 | .DS_Store
6 | .AppleDouble
7 | .LSOverride
8 | Icon
9 | ._*
10 | .Spotlight-V100
11 | .Trashes
12 |
13 | ## Windows
14 | Thumbs.db
15 | ehthumbs.db
16 | Desktop.ini
17 | $RECYCLE.BIN/
18 |
--------------------------------------------------------------------------------
/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "node": true,
3 | "browser": true,
4 | "esnext": true,
5 | "bitwise": true,
6 | "camelcase": true,
7 | "curly": false,
8 | "eqeqeq": true,
9 | "indent": 2,
10 | "loopfunc": true,
11 | "immed": true,
12 | "latedef": true,
13 | "newcap": true,
14 | "noarg": true,
15 | "quotmark": "single",
16 | "regexp": true,
17 | "undef": true,
18 | "unused": false,
19 | "trailing": false,
20 | "sub": true,
21 | "globals": {
22 | "angular": true
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig helps developers define and maintain consistent
2 | # coding styles between different editors and IDEs
3 | # editorconfig.org
4 |
5 | root = true
6 |
7 | [*]
8 |
9 | # Change these settings to your own preference
10 | indent_style = space
11 | indent_size = 2
12 |
13 | # We recommend you to keep these unchanged
14 | end_of_line = lf
15 | charset = utf-8
16 | trim_trailing_whitespace = true
17 | insert_final_newline = true
18 |
19 | [*.md]
20 | trim_trailing_whitespace = false
21 |
--------------------------------------------------------------------------------
/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "angular-component.js",
3 | "version": "0.0.7",
4 | "main": "./dist/angular-component.min.js",
5 | "dependencies": {
6 | "angular": ">=1.3.0 <=1.5"
7 | },
8 | "homepage": "https://github.com/toddmotto/angular-component",
9 | "authors": [
10 | "Todd Motto "
11 | ],
12 | "description": "Angular component() polyfill for v1.3+",
13 | "moduleType": [],
14 | "keywords": [
15 | "Angular",
16 | "Component",
17 | "Directives"
18 | ],
19 | "license": "MIT",
20 | "ignore": [
21 | "**/.*",
22 | "node_modules",
23 | "bower_components",
24 | "test",
25 | "tests"
26 | ]
27 | }
28 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "angular-component",
3 | "version": "0.1.3",
4 | "main": "./dist/angular-component.min.js",
5 | "description": "Angular component() polyfill",
6 | "author": "@toddmotto",
7 | "license": "MIT",
8 | "homepage": "https://github.com/toddmotto/angular-component",
9 | "repository": {
10 | "type": "git",
11 | "url": "https://github.com/toddmotto/angular-component.git"
12 | },
13 | "devDependencies": {
14 | "gulp": "~3.9.0",
15 | "gulp-uglify": "~0.3.0",
16 | "gulp-rename": "~1.1.0",
17 | "gulp-clean": "^0.2.4",
18 | "gulp-plumber": "~0.6.2",
19 | "gulp-header": "^1.0.2",
20 | "gulp-jshint": "^1.6.1",
21 | "jshint-stylish": "^0.2.0"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | LICENSE
2 |
3 | The MIT License
4 |
5 | Copyright (c) 2015 Todd Motto
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 |
--------------------------------------------------------------------------------
/gulpfile.js:
--------------------------------------------------------------------------------
1 | var gulp = require('gulp'),
2 | jshint = require('gulp-jshint'),
3 | stylish = require('jshint-stylish'),
4 | header = require('gulp-header'),
5 | uglify = require('gulp-uglify'),
6 | plumber = require('gulp-plumber'),
7 | clean = require('gulp-clean'),
8 | rename = require('gulp-rename'),
9 | package = require('./package.json');
10 |
11 | var paths = {
12 | output : 'dist/',
13 | scripts : [
14 | 'src/angular-component.js'
15 | ],
16 | test: [
17 | 'test/spec/**/*.js'
18 | ]
19 | };
20 |
21 | var banner = [
22 | '/*! ',
23 | '<%= package.name %> ',
24 | 'v<%= package.version %> | ',
25 | '(c) ' + new Date().getFullYear() + ' <%= package.author %> |',
26 | ' <%= package.homepage %>',
27 | ' */',
28 | '\n'
29 | ].join('');
30 |
31 | gulp.task('scripts', ['clean'], function() {
32 | return gulp.src(paths.scripts)
33 | .pipe(plumber())
34 | .pipe(header(banner, { package : package }))
35 | .pipe(gulp.dest('dist/'))
36 | .pipe(rename({ suffix: '.min' }))
37 | .pipe(uglify())
38 | .pipe(header(banner, { package : package }))
39 | .pipe(gulp.dest('dist/'));
40 | });
41 |
42 | gulp.task('lint', function () {
43 | return gulp.src(paths.scripts)
44 | .pipe(plumber())
45 | .pipe(jshint())
46 | .pipe(jshint.reporter('jshint-stylish'));
47 | });
48 |
49 | gulp.task('clean', function () {
50 | return gulp.src(paths.output, { read: false })
51 | .pipe(plumber())
52 | .pipe(clean());
53 | });
54 |
55 | gulp.task('default', [
56 | 'lint',
57 | 'clean',
58 | 'scripts'
59 | ]);
60 |
--------------------------------------------------------------------------------
/dist/angular-component.min.js:
--------------------------------------------------------------------------------
1 | /*! angular-component v0.1.3 | (c) 2017 @toddmotto | https://github.com/toddmotto/angular-component */
2 | !function(){function n(n,t){if(t&&"string"==typeof t)return t;if("string"==typeof n){var r=/^(\S+)(\s+as\s+(\w+))?$/.exec(n);if(r)return r[3]}}function t(){function t(t,r){function o(e){function o(n){var t=angular.isArray(n);return angular.isFunction(n)||t?function(r,o){return e.invoke(t?n:["$element","$attrs",n],this,{$element:r,$attrs:o})}:n}function a(n){var t={};for(var r in n){var e=n[r];if("<"===e.charAt(0)){var o=e.substring(1);i.unshift({local:r,attr:""===o?r:o})}else t[r]=e}return t}var i=[],l=a(r.bindings),u=[t],c=[];if(angular.isObject(r.require))for(var f in r.require)u.push(r.require[f]),c.push(f);return{controller:r.controller||angular.noop,controllerAs:n(r.controller)||r.controllerAs||"$ctrl",template:o(r.template||r.templateUrl?r.template:""),templateUrl:o(r.templateUrl),transclude:r.transclude,scope:l||{},bindToController:!!l,restrict:"E",require:u,link:{pre:function(n,t,r,e){function o(){l.$onChanges(f),f=void 0}function a(n,t,r,e){"function"==typeof l.$onChanges&&(f||(f={}),f[n]&&(r=f[n].currentValue),f[n]={currentValue:t,previousValue:r},e&&o())}for(var l=e[0],u=0;u [View live demo in v1.3.0](https://jsfiddle.net/vz53audf)
6 |
7 | angular-component.js is a `~1kb` script that adds `component()` support in Angular 1.5 to all Angular versions above `1.3`, so you can begin using the new method now.
8 |
9 | _Note_: you must include this script straight after `angular.js` and before your application code to ensure the `component()` method has been added to the `angular.module` global.
10 |
11 | > Read about the Angular 1.5 `component()` method [here](http://toddmotto.com/exploring-the-angular-1-5-component-method)
12 |
13 | ### Polyfill support
14 |
15 | This polyfill supports the following feature set of the `.component()` method:
16 |
17 | | Feature | Supports |
18 | |----------------------------------------------------------------|-----------|
19 | | `angular.module.component()` method | Yes |
20 | | `bindings` property | Yes |
21 | | `'E'` restrict default | Yes |
22 | | `$ctrl` controllerAs default | Yes |
23 | | `transclude` property | Yes |
24 | | `template` support | Yes |
25 | | `templateUrl` injectable for `$element` and `$attrs` | Yes |
26 | | One-way data-binding emulated | Yes |
27 | | Lifecycles: `$onInit`, `$onChanges`m `$postLink`, `$onDestroy` | Yes |
28 | | `require` Object for parent Component inheritance | Yes |
29 | | `$` prefixed properties such as `$canActivate` | Yes |
30 |
31 | ### Component method usage
32 |
33 | ```html
34 |
39 |
40 |
89 | ```
90 |
91 | ## Installing with NPM
92 |
93 | ```
94 | npm install angular-component --save
95 | ```
96 |
97 | ## Installing with Bower
98 |
99 | ```
100 | bower install angular-component.js --save
101 | ```
102 |
103 | ## Manual installation
104 | Ensure you're using the files from the `dist` directory (contains compiled production-ready code). Ensure you place the script before the closing `
108 |
109 |
110 |
111 |
112 |