Skip to content

Commit

Permalink
First commit: added angular directive
Browse files Browse the repository at this point in the history
  • Loading branch information
alessiocancian committed Apr 16, 2016
0 parents commit 385ad89
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions angular-bootstrap-iconpicker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
var app = angular.module('bootstrap-iconpicker', []);
app.directive('iconpicker', function(){
return {
restrict: 'A',
scope: {
iconChanged: '&'
},
require: 'ngModel',
link: function($scope, elem, attr, ngModel) {
$(elem).iconpicker();
$(elem).on('change', function(e) {
ngModel.$setViewValue(e.icon);
if($scope.iconChanged())
$scope.iconChanged()({scope: $scope, elem: elem, icon: e.icon});
});
$scope.$watch(function() {
return ngModel.$modelValue;
}, function(modelValue) {
$(elem).iconpicker('setIcon', modelValue);
});
}
}
});

0 comments on commit 385ad89

Please sign in to comment.