Last active
November 16, 2015 16:52
-
-
Save jasperboyd/058343e2b74e12196dd5 to your computer and use it in GitHub Desktop.
Directive Boilerplate
This file contains 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="../../../../../client/typings/tsd.d.ts" /> | |
/// <reference path="../../../../../client/typings/slatwallTypeScript.d.ts" /> | |
module slatwalladmin { | |
'use strict'; | |
export class yourDirectiveControllerClass{ | |
public giftCardId; | |
public giftCard; | |
public static $inject = ["collectionConfigService"]; | |
constructor(private collectionConfigService:CollectionConfig){ | |
} | |
public getGiftCardCollectionConfig = ():void =>{ | |
var giftCardConfig = this.collectionConfigService.newCollectionConfig('GiftCard'); | |
giftCardConfig.setDisplayProperties("giftCardID, giftCardCode, currencyCode, giftCardPin, expirationDate, ownerFirstName, ownerLastName, ownerEmailAddress, activeFlag, balanceAmount, originalOrderItem.sku.product.productName, originalOrderItem.sku.product.productID, originalOrderItem.order.orderID, originalOrderItem.orderItemID, orderItemGiftRecipient.firstName, orderItemGiftRecipient.lastName, orderItemGiftRecipient.emailAddress, orderItemGiftRecipient.giftMessage"); | |
giftCardConfig.addFilter('giftCardID', this.giftCardId); | |
giftCardConfig.setAllRecords(true); | |
return giftCardConfig; | |
} | |
} | |
export class yourDirectiveClass implements ng.IDirective { | |
public static $inject = ["collectionConfigService", "partialsPath"]; | |
public restrict:string; | |
public templateUrl:string; | |
public scope = {}; | |
public bindToController = { | |
giftCardId:"@", | |
giftCard:"=?" | |
}; | |
public controller= yourDirectiveControllerClass; | |
public controllerAs="controllerName"; | |
constructor(private collectionConfigService:slatwalladmin.CollectionConfig, private partialsPath){ | |
//partials path is admin/client/partials | |
this.templateUrl = partialsPath + "/path/to/template.html"; | |
this.restrict = "E"; | |
} | |
public link:ng.IDirectiveLinkFn = (scope: ng.IScope, element: ng.IAugmentedJQuery, attrs:ng.IAttributes) =>{ | |
} | |
} | |
angular.module('slatwalladmin') | |
.directive('yourDirectiveName', | |
["collectionConfigService", "partialsPath", | |
(collectionConfigService, partialsPath) => | |
new yourDirectiveClass(collectionConfigService, partialsPath) | |
]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment