Last active
August 29, 2015 14:21
-
-
Save droyad/d094ebaef382b40a973a to your computer and use it in GitHub Desktop.
Directive example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// <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); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The interface declarations are optional