MANOJ G I'm using something like below for Directive and it seems like working, But not able to find a proper example for Filters
import template from './test.directive.html';
class ExampleDirective {
constructor($http) {
this.templateUrl = template; // Template or template Url
this.restrict = 'E'; // Element, Attribute, Class or Comment
this.scope = { // Bindings required
oneWay: '@',
twoWay: '=',
testFn: '&'
};
this.controllerAs = 'eCtrl';
this.bindToController = true; //This will bind data to controller's this but not to scope. So it's good to use it.
this.controller = ExampleController; //Controller Initialization
this.$http = $http; // Dependencies for Directive, if any required
}
link(scope, ele, attrs) { // Link function
console.log('LINK FUNCTION:', scope, ele, attrs);
}
static directiveFactory($http){ // This is what is exposed for directive
ExampleDirective.instance = new ExampleDirective($http);
return ExampleDirective.instance;
}
}
ExampleDirective.directiveFactory.$inject = ['$http']; // Inject Dependencies for Directive
class ExampleController {
constructor($scope, $http) {
console.log('DIRECTIVE CONTROLLER');
this.$scope = $scope;
this.$http = $http;
}
}
ExampleController.$inject = ['$scope', '$http']; // Inject Dependencies for Controller
export default angular.module('yourApp').directive('testDir', ExampleDirective.directiveFactory);