Created
January 23, 2016 15:31
-
-
Save franklinjavier/39e24eb4aa880e732e53 to your computer and use it in GitHub Desktop.
Rating in angularjs
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
angular.module('plunker', []) | |
.directive('rating', function() { | |
return { | |
scope: { | |
rate: '=', | |
onUpdate: '&' | |
}, | |
templateUrl: 'rating.html', | |
link: function(scope, element, attrs) { | |
scope.range = [1,2,3,4,5]; | |
scope.update = function(value) { | |
scope.rate = value; | |
if (scope.onUpdate) { | |
scope.onUpdate({value: value}); | |
} | |
}; | |
} | |
}; | |
}) | |
.controller('MainCtrl', function($scope) { | |
$scope.rate = 2; | |
$scope.onUpdate = function(value) { | |
console.log('here'); | |
$scope.customRate = value / 5; | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment