Skip to content

Instantly share code, notes, and snippets.

@martinrusev
Created June 9, 2014 10:39
Show Gist options
  • Select an option

  • Save martinrusev/53c89b1a0867ac74bbdf to your computer and use it in GitHub Desktop.

Select an option

Save martinrusev/53c89b1a0867ac74bbdf to your computer and use it in GitHub Desktop.
Select2/Angular Integration
"use strict";
var el;
var underscore = angular.module('underscore', []);
underscore.factory('_', function() {
return window._;
});
var app = angular.module('DashboardApp', ['underscore'])
.controller('DashboardCtrl', function($scope){
$scope.AddMetric = function(name) {
console.log(el.select2('val'))
};
})
.directive('dashboardDropdown', function($window) {
return {
restrict: 'A',
scope: {},
controller: ['$scope', '$element', '$attrs',
function($scope, $element, $attrs) {
}],
link: function(scope, element, attrs) {
el = jQuery(element);
el.select2();
} // link
}; // return
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment