-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
33 lines (25 loc) · 735 Bytes
/
Copy pathapp.js
File metadata and controls
33 lines (25 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
(function () {
'use strict';
angular.module('myAngApp', [])
.controller('MyController', MyController);
MyController.$inject = [$scope, $filter]
function MyController ($scope, $filter) {
$scope.name = '';
$scope.totalValue = 0;
$scope.upper = function () {
var upCase = $filter('uppercase');
$scope.name = upCase($scope.name);
};
$scope.displayNum = function () {
var totalNameValue = calcNumForString($scope.name);
$scope.totalValue = totalNameValue;
};
function calcNumForString(str) {
var totalStrVal = 0;
for (var i = 0; i < str.length; i++) {
totalStrVal += str.charCodeAt(i);
}
return totalStrVal;
}
};
})();