Plato on Github
Report Home
directives/string_to_number.js
Maintainability
86.32
Lines of code
21
Difficulty
5.17
Estimated Errors
0.08
Function weight
By Complexity
By SLOC
'use strict'; /** * @ngdoc directive * @name SnsApp.directive:stringToNumber * @description * # stringToNumber */ angular.module('SnsApp') .directive('stringToNumber', function() { return { require: 'ngModel', link: function(scope, element, attrs, ngModel) { ngModel.$parsers.push(function(value) { return '' + value; }); ngModel.$formatters.push(function(value) { return parseFloat(value, 10); }); } }; });