Skip to content

Instantly share code, notes, and snippets.

@droyad
Last active August 29, 2015 14:21
Show Gist options
  • Select an option

  • Save droyad/d094ebaef382b40a973a to your computer and use it in GitHub Desktop.

Select an option

Save droyad/d094ebaef382b40a973a to your computer and use it in GitHub Desktop.
Directive example
/// <reference path="../../app.ts"/>
module Foo.AddBarAuditLink {
class Controller {
barId: number;
constructor($scope, $modal) {
$scope.open = () => {
$modal.open({
template: "<bar-audit-editor bar-id='" + this.varId + "'></bar-audit-editor>",
size: 'lg'
});
}
}
}
interface IDirectiveScope extends ng.IScope {
ctrl: Controller;
}
interface IAttributes extends ng.IAttributes {
barId: number
}
var directiveFactory = () => ({
template: "<a href=\"#\" ng-click=\"open()\">Add Audit</a>",
controller: Controller,
controllerAs: "ctrl",
link(scope: IDirectiveScope, element: ng.IAugmentedJQuery, attrs: IAttributes) {
scope.ctrl.barId = attrs.barId;
}
});
Fams.app.directive("addBarAuditLink", directiveFactory);
}
@droyad
Copy link
Author

droyad commented May 14, 2015

The interface declarations are optional

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment