Skip to content

Instantly share code, notes, and snippets.

@B3nCr
Last active August 29, 2015 14:27
Show Gist options
  • Save B3nCr/3ab8d673b1589af2f66a to your computer and use it in GitHub Desktop.
Save B3nCr/3ab8d673b1589af2f66a to your computer and use it in GitHub Desktop.
module MyModule {
'use strict';
export class MaterialNameDirective {
public link: (scope: any /* IProjectsScope*/, element: any/*ng.IAugmentedJQuery*/, attrs: any /*ng.IAttributes*/) => void;
public template = '<div>{{name}}</div>';
constructor(private materialService: Material.MaterialService) {
// It's important to add `link` to the prototype or you will end up with state issues.
// See http://blog.aaronholmes.net/writing-angularjs-directives-as-typescript-classes/#comment-2111298002 for more information.
MaterialNameDirective.prototype.link = (scope: any/*IProjectsScope*/, element: any/*ng.IAugmentedJQuery*/, attrs: any /* ng.IAttributes */) => {
scope.name = 'Material Name';
scope.name = materialService.getMaterialName(17).Description;
};
}
public static Factory() {
var directive = (materialService: Material.MaterialService) => {
return new MaterialNameDirective(materialService);
};
// these inject services get injected into the constructor.
directive['$inject'] = ['MaterialService'];
return directive;
}
static register() {
angular.module('RT.AutoConstruction')
.directive('rtMaterialName', MaterialNameDirective.Factory());
}
}
export class AlertTypeDirective {
public link: (scope: any /* IProjectsScope*/, element: any/*ng.IAugmentedJQuery*/, attrs: any /*ng.IAttributes*/) => void;
public template = '<div>{{name}}</div>';
constructor() {
// It's important to add `link` to the prototype or you will end up with state issues.
// See http://blog.aaronholmes.net/writing-angularjs-directives-as-typescript-classes/#comment-2111298002 for more information.
AlertTypeDirective.prototype.link = (scope: any/*IProjectsScope*/, element: any/*ng.IAugmentedJQuery*/, attrs: any /* ng.IAttributes */) => {
scope.name = 'Alert Type';
};
}
public static Factory() {
var directive = () => {
return new AlertTypeDirective();
};
// these inject services get injected into the constructor.
directive['$inject'] = [];
return directive;
}
static register() {
angular.module('RT.AutoConstruction')
.directive('rtAlertType', AlertTypeDirective.Factory());
}
}
AlertTypeDirective.register();
MaterialNameDirective.register();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment