Created
November 10, 2014 03:35
-
-
Save garciadanny/98acda3462f3edf89c16 to your computer and use it in GitHub Desktop.
BlogPost: AngularJS Custom Directives
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
... | |
myApp.directive('selectFilter', ['$compile', function($compile) { | |
return { | |
restrict: 'E', | |
link: function(scope, element, attrs) { | |
var model = attrs.model; | |
var modelList = pluralize(model); | |
var attribute = attrs.attribute; | |
var jadeString = "select(ng-model='#{attribute}', ng-options=\"#{model}.#{attribute} as #{model}.#{attribute} for #{model} in #{modelList} | unique:'#{attribute}'\")" + "\n\toption(value='') All"; | |
var jadeTemplate = jade.compile(jadeString); | |
var html = jadeTemplate({model: model, attribute: attribute, modelList: modelList}); | |
var c = $compile(html)(scope); | |
element.append(c); | |
} | |
}; | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment