angular-es6
Advanced tools
Comparing version 2.0.3 to 2.0.4
{ | ||
"name": "angular-es6", | ||
"description": "ECMAScript 6 boilerplate for angular source code and webpack", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"private": false, | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -40,3 +40,3 @@ # Angular ECMAScript 6 config and boilerplate | ||
this.scope = scope; | ||
scope.computeName = suffix => computeName(suffix); | ||
scope.computeName = (suffix) => this.computeName(suffix); | ||
} | ||
@@ -47,3 +47,3 @@ | ||
return 'Mr.' + $scope.name + ' ' + suffix; | ||
return 'Mr.' + scope.name + ' ' + suffix; | ||
} | ||
@@ -59,3 +59,3 @@ } | ||
export default class MainController { | ||
static $inject = [$scope, '$http']; | ||
static $inject = ['$scope', '$http']; | ||
@@ -78,4 +78,4 @@ constructor($scope, $http) { | ||
As you can see in the examples below. You need to store injected objects somehow. | ||
There is a better solution. You can extend you class with class Inject and use variable named this.$inject. | ||
As you can see in the examples above. You need to store injected objects somehow. | ||
There is a better solution. You can extend you class with class named Inject and then you can use variable named this.$inject. | ||
@@ -106,3 +106,35 @@ In next example is called function doThis from the constructor. | ||
### Directive auto Inject | ||
You can use variables from the link function anywhere in your directive code. | ||
This feature is available without extending Inject class. Here is small example | ||
```js | ||
export default class NiceDirective { | ||
static $inject = ['$http']; | ||
constructor($http) { | ||
this.$http = $http; | ||
this.template = '<div>{{computeName('NICE')}}</div>'; | ||
this.restrict = 'E'; | ||
this.scope = { | ||
name: '=', | ||
}; | ||
} | ||
link(scope) { | ||
scope.computeName = (suffix) => this.computeName(suffix); | ||
} | ||
computeName(suffix = '') { | ||
const { scope, element } = this.link.$inject; | ||
element.text('Mr.' + scope.name + ' ' + suffix); | ||
} | ||
} | ||
``` | ||
### Auto load directives | ||
@@ -114,4 +146,6 @@ | ||
import { load } from 'angular-es6'; | ||
const MODULE_NAME = 'directives'; | ||
load.directives(require.context('./', true, /.*\.js$/)); | ||
export default MODULE_NAME; | ||
``` | ||
@@ -118,0 +152,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26047
169